mirror of
https://github.com/XcodesOrg/XcodesApp.git
synced 2026-03-25 08:55:46 +00:00
Catch and reword xip "not enough free space" error
This commit is contained in:
parent
d834f3ed74
commit
91293557ec
2 changed files with 49 additions and 2 deletions
|
|
@ -206,10 +206,15 @@ extension AppState {
|
|||
|
||||
return Current.shell.unxip(source)
|
||||
.catch { error -> AnyPublisher<ProcessOutput, Swift.Error> in
|
||||
if let executionError = error as? ProcessExecutionError,
|
||||
executionError.standardError.contains("damaged and can’t be expanded") {
|
||||
if let executionError = error as? ProcessExecutionError {
|
||||
if executionError.standardError.contains("damaged and can’t be expanded") {
|
||||
return Fail(error: InstallationError.damagedXIP(url: source))
|
||||
.eraseToAnyPublisher()
|
||||
} else if executionError.standardError.contains("can’t be expanded because the selected volume doesn’t have enough free space.") {
|
||||
return Fail(error: InstallationError.notEnoughFreeSpaceToExpandArchive(archivePath: Path(url: source)!,
|
||||
version: availableXcode.version))
|
||||
.eraseToAnyPublisher()
|
||||
}
|
||||
}
|
||||
return Fail(error: error)
|
||||
.eraseToAnyPublisher()
|
||||
|
|
@ -365,6 +370,7 @@ extension AppState {
|
|||
|
||||
public enum InstallationError: LocalizedError, Equatable {
|
||||
case damagedXIP(url: URL)
|
||||
case notEnoughFreeSpaceToExpandArchive(archivePath: Path, version: Version)
|
||||
case failedToMoveXcodeToApplications
|
||||
case failedSecurityAssessment(xcode: InstalledXcode, output: String)
|
||||
case codesignVerifyFailed(output: String)
|
||||
|
|
@ -383,6 +389,12 @@ public enum InstallationError: LocalizedError, Equatable {
|
|||
switch self {
|
||||
case .damagedXIP(let url):
|
||||
return "The archive \"\(url.lastPathComponent)\" is damaged and can't be expanded."
|
||||
case let .notEnoughFreeSpaceToExpandArchive(archivePath, version):
|
||||
return """
|
||||
The archive “\(archivePath.basename())” can’t be expanded because the current volume doesn’t have enough free space.
|
||||
|
||||
Make more space available to expand the archive and then install Xcode \(version.appleDescription) again to start installation from where it left off.
|
||||
"""
|
||||
case .failedToMoveXcodeToApplications:
|
||||
return "Failed to move Xcode to the /Applications directory."
|
||||
case .failedSecurityAssessment(let xcode, let output):
|
||||
|
|
|
|||
|
|
@ -280,4 +280,39 @@ class AppStateTests: XCTestCase {
|
|||
)
|
||||
}
|
||||
|
||||
func test_Install_NotEnoughFreeSpace() throws {
|
||||
Current.shell.unxip = { _ in
|
||||
Fail(error: ProcessExecutionError(
|
||||
process: Process(),
|
||||
standardOutput: "xip: signing certificate was \"Development Update\" (validation not attempted)",
|
||||
standardError: "xip: error: The archive “Xcode-12.4.0-Release.Candidate+12D4e.xip” can’t be expanded because the selected volume doesn’t have enough free space."
|
||||
))
|
||||
.eraseToAnyPublisher()
|
||||
}
|
||||
let archiveURL = URL(fileURLWithPath: "/Users/user/Library/Application Support/Xcode-0.0.0.xip")
|
||||
|
||||
let recorder = subject.unarchiveAndMoveXIP(
|
||||
availableXcode: AvailableXcode(
|
||||
version: Version("0.0.0")!,
|
||||
url: URL(string: "https://developer.apple.com")!,
|
||||
filename: "Xcode-0.0.0.xip",
|
||||
releaseDate: nil
|
||||
),
|
||||
at: archiveURL,
|
||||
to: URL(string: "/Applications/Xcode-0.0.0.app")!
|
||||
).record()
|
||||
|
||||
let completion = try wait(for: recorder.completion, timeout: 1, description: "Completion")
|
||||
|
||||
if case let .failure(error as InstallationError) = completion {
|
||||
XCTAssertEqual(
|
||||
error,
|
||||
InstallationError.notEnoughFreeSpaceToExpandArchive(archivePath: Path(url: archiveURL)!,
|
||||
version: Version("0.0.0")!)
|
||||
)
|
||||
}
|
||||
else {
|
||||
XCTFail()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue