mirror of
https://github.com/XcodesOrg/XcodesApp.git
synced 2026-03-25 08:55:46 +00:00
Merge pull request #79 from RobotsAndPencils/not-enough-free-space-error
Catch and reword xip "not enough free space" error
This commit is contained in:
commit
6d2fce2078
3 changed files with 53 additions and 4 deletions
|
|
@ -51,6 +51,7 @@
|
|||
CAA858C425A2BE4E00ACF8C0 /* Downloader.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAA858C325A2BE4E00ACF8C0 /* Downloader.swift */; };
|
||||
CAA858CD25A3D8BC00ACF8C0 /* ErrorHandling in Frameworks */ = {isa = PBXBuildFile; productRef = CAA858CC25A3D8BC00ACF8C0 /* ErrorHandling */; };
|
||||
CAA858DB25A3E11F00ACF8C0 /* aria2-release-1.35.0.tar.gz in Resources */ = {isa = PBXBuildFile; fileRef = CAA858DA25A3E11F00ACF8C0 /* aria2-release-1.35.0.tar.gz */; };
|
||||
CAB3AB0E25BCA6C200BF1B04 /* AppStateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAD2E7B72449575100113D76 /* AppStateTests.swift */; };
|
||||
CABFA9BB2592EEEA00380FEE /* DateFormatter+.swift in Sources */ = {isa = PBXBuildFile; fileRef = CABFA9BA2592EEEA00380FEE /* DateFormatter+.swift */; };
|
||||
CABFA9BD2592EEEA00380FEE /* Environment.swift in Sources */ = {isa = PBXBuildFile; fileRef = CABFA9A92592EEE900380FEE /* Environment.swift */; };
|
||||
CABFA9BF2592EEEA00380FEE /* URLSession+DownloadTaskPublisher.swift in Sources */ = {isa = PBXBuildFile; fileRef = CABFA9B32592EEEA00380FEE /* URLSession+DownloadTaskPublisher.swift */; };
|
||||
|
|
@ -808,6 +809,7 @@
|
|||
CAC281E7259FA45A00B8AB0B /* Environment+Mock.swift in Sources */,
|
||||
CAC281E2259FA44600B8AB0B /* Bundle+XcodesTests.swift in Sources */,
|
||||
CA2518EC25A7FF2B00F08414 /* AppStateUpdateTests.swift in Sources */,
|
||||
CAB3AB0E25BCA6C200BF1B04 /* AppStateTests.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ class AppStateTests: XCTestCase {
|
|||
[.installing(.trashingArchive), .notInstalled, .notInstalled],
|
||||
[.installing(.checkingSecurity), .notInstalled, .notInstalled],
|
||||
[.installing(.finishing), .notInstalled, .notInstalled],
|
||||
[.installed, .notInstalled, .notInstalled]
|
||||
[.installed(Path("/Applications/Xcode-0.0.0.app")!), .notInstalled, .notInstalled]
|
||||
]
|
||||
)
|
||||
}
|
||||
|
|
@ -275,9 +275,44 @@ class AppStateTests: XCTestCase {
|
|||
[.installing(.trashingArchive), .notInstalled, .notInstalled],
|
||||
[.installing(.checkingSecurity), .notInstalled, .notInstalled],
|
||||
[.installing(.finishing), .notInstalled, .notInstalled],
|
||||
[.installed, .notInstalled, .notInstalled]
|
||||
[.installed(Path("/Applications/Xcode-0.0.0.app")!), .notInstalled, .notInstalled]
|
||||
]
|
||||
)
|
||||
}
|
||||
|
||||
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