Skip to content

Commit b4dd917

Browse files
authored
Merge pull request #6 from hstdt/fix/dangling-xcode-symlink
Handle dangling Xcode selection symlinks
2 parents a9e5d7d + 5c7eeae commit b4dd917

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎Sources/XcodesKit/Services/XcodeSelectionFilesystemService.swift‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,14 @@ public struct XcodeSelectionFilesystemService: Sendable {
6565
let destinationPath = installDirectory/"Xcode\(isBeta ? "-Beta" : "").app"
6666
var replacedExistingSymlink = false
6767

68-
if fileExists(destinationPath.string) {
69-
let attributes = try attributesOfItem(destinationPath.string)
68+
let attributes: [FileAttributeKey: Any]?
69+
do {
70+
attributes = try attributesOfItem(destinationPath.string)
71+
} catch let error as CocoaError where error.code == .fileReadNoSuchFile {
72+
attributes = nil
73+
}
74+
75+
if let attributes {
7076
if attributes[.type] as? FileAttributeType == .typeSymbolicLink {
7177
try removeItem(destinationPath.string)
7278
replacedExistingSymlink = true

0 commit comments

Comments
 (0)