mac-crafter: Check if path to trecursively codesign exists and throw error if it...
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Thu, 5 Dec 2024 07:49:38 +0000 (15:49 +0800)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Mon, 9 Dec 2024 08:10:16 +0000 (08:10 +0000)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
admin/osx/mac-crafter/Sources/Utils/Codesign.swift

index be7eb586d6da910aa1ebafd124eca64caa982449..4b2341274c0b3b7d87492052c5de11a9fd2de73b 100644 (file)
@@ -21,6 +21,7 @@ enum CodeSigningError: Error {
 }
 
 enum AppBundleSigningError: Error {
+    case doesNotExist(String)
     case couldNotEnumerate(String)
 }
 
@@ -64,6 +65,10 @@ func recursivelyCodesign(
     skip: [String] = []
 ) throws {
     let fm = FileManager.default
+    guard fm.fileExists(atPath: path) else {
+        throw AppBundleSigningError.doesNotExist("Item at \(path) does not exist.")
+    }
+
     guard let pathEnumerator = fm.enumerator(atPath: path) else {
         throw AppBundleSigningError.couldNotEnumerate(
             "Failed to enumerate directory at \(path)."