Skip to content

Commit 877640a

Browse files
committed
Fingerprint storage error handling
Motivation: CI failure: https://ci.swift.org/job/swift-PR-source-compat-suite/5701/artifact/swift-source-compat-suite/ ``` error: Failed to get source control fingerprint for swift-log remoteSourceControl https://github.com/apple/swift-log.git version 1.4.2 from storage: Error Domain=NSCocoaErrorDomain Code=513 "You don't have permission to save the file "fingerprints" in the folder "security"." UserInfo={NSFilePath=/Users/buildnode/.swiftpm/security/fingerprints, NSUnderlyingError=0x7feaae439370 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}} error: Error Domain=NSCocoaErrorDomain Code=513 "You don't have permission to save the file "fingerprints" in the folder "security"." UserInfo={NSFilePath=/Users/buildnode/.swiftpm/security/fingerprints, NSUnderlyingError=0x7feaae439370 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}} ``` Modifications: `FilePackageFingerprintStorage` to emit warning instead of failing if there are file system related issues.
1 parent e4de038 commit 877640a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Sources/PackageFingerprint/FilePackageFingerprintStorage.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,12 @@ public struct FilePackageFingerprintStorage: PackageFingerprintStorage {
4848
}
4949

5050
callback(.success(fingerprints))
51-
} catch {
51+
} catch let error as PackageFingerprintStorageError {
5252
callback(.failure(error))
53+
} catch {
54+
// Error might be due to file system permission issues, which we don't
55+
// have control over, so log instead of throw.
56+
observabilityScope.emit(warning: "Failed to read fingerprints for \(package): \(error)")
5357
}
5458
}
5559

@@ -82,8 +86,12 @@ public struct FilePackageFingerprintStorage: PackageFingerprintStorage {
8286
try self.saveToDisk(package: package, fingerprints: packageFingerprints)
8387
}
8488
callback(.success(()))
85-
} catch {
89+
} catch let error as PackageFingerprintStorageError {
8690
callback(.failure(error))
91+
} catch {
92+
// Error might be due to file system permission issues, which we don't
93+
// have control over, so log instead of throw.
94+
observabilityScope.emit(warning: "Failed to write fingerprints for \(package): \(error)")
8795
}
8896
}
8997

0 commit comments

Comments
 (0)