diff --git a/Sources/XcodesKit/Models/XcodeInstallState.swift b/Sources/XcodesKit/Models/XcodeInstallState.swift index e8e495a..ab4bfc3 100644 --- a/Sources/XcodesKit/Models/XcodeInstallState.swift +++ b/Sources/XcodesKit/Models/XcodeInstallState.swift @@ -16,6 +16,8 @@ public enum XcodeInstallState: Equatable, Sendable { case installing(XcodeInstallationStep) /// The Xcode is installed at the associated path. case installed(Path) + /// The Xcode at the associated path is being uninstalled. + case uninstalling(Path) /// Whether the state is ``notInstalled``. public var notInstalled: Bool { @@ -38,11 +40,19 @@ public enum XcodeInstallState: Equatable, Sendable { default: return false } } + /// Whether the state is ``uninstalling(_:)``. + public var uninstalling: Bool { + switch self { + case .uninstalling: return true + default: return false + } + } - /// The installed path when the state is ``installed(_:)``. + /// The installed path when the state is ``installed(_:)`` or ``uninstalling(_:)``. public var installedPath: Path? { switch self { case .installed(let path): return path + case .uninstalling(let path): return path default: return nil } } diff --git a/Sources/XcodesKit/Services/XcodeUnarchiveService.swift b/Sources/XcodesKit/Services/XcodeUnarchiveService.swift index 6843ab2..dad6500 100644 --- a/Sources/XcodesKit/Services/XcodeUnarchiveService.swift +++ b/Sources/XcodesKit/Services/XcodeUnarchiveService.swift @@ -13,7 +13,7 @@ public enum XcodeUnarchiveStep: Equatable, Sendable { public struct XcodeUnarchiveService: Sendable { public typealias Unarchive = @Sendable (URL) async throws -> Void public typealias FileExists = @Sendable (String) -> Bool - public typealias MoveItem = @Sendable (URL, URL) throws -> Void + public typealias MoveItem = @Sendable (URL, URL) async throws -> Void public typealias RemoveItem = @Sendable (URL) throws -> Void public typealias StepChanged = @Sendable (XcodeUnarchiveStep) async -> Void @@ -81,9 +81,9 @@ public struct XcodeUnarchiveService: Sendable { let xcodeURL = source.deletingLastPathComponent().appendingPathComponent("Xcode.app") let xcodeBetaURL = source.deletingLastPathComponent().appendingPathComponent("Xcode-beta.app") if fileExists(xcodeURL.path) { - try moveItem(xcodeURL, destination) + try await moveItem(xcodeURL, destination) } else if fileExists(xcodeBetaURL.path) { - try moveItem(xcodeBetaURL, destination) + try await moveItem(xcodeBetaURL, destination) } return destination