Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion Sources/XcodesKit/Models/XcodeInstallState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/XcodesKit/Services/XcodeUnarchiveService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down