Modern Apps git

← xtool.git

Turns out KeychainStorage was broken oops

Commit
92a0108c53965bb69597b84f724073124e9c3c86
Author
kabiroberai <[email protected]>
When
2021-02-03 22:41 UTC (5 years ago)
Parents
7933514

Diff

Supersign/Utilities/KeyValueStorage.swift
diff --git a/Supersign/Utilities/KeyValueStorage.swift b/Supersign/Utilities/KeyValueStorage.swiftindex 4980ffe..14b7a52 100644--- a/Supersign/Utilities/KeyValueStorage.swift+++ b/Supersign/Utilities/KeyValueStorage.swift@@ -55,8 +55,9 @@ public struct KeychainStorage: KeyValueStorage {      private let lock = NSLock() -    private static func check(_ result: OSStatus) throws {+    private static func check(_ result: OSStatus, ignoreNotFound: Bool = false) throws {         if result != errSecSuccess {+            if ignoreNotFound && result == errSecItemNotFound { return }             let info: [String: Any]?             if #available(iOS 11.3, *), let message = SecCopyErrorMessageString(result, nil) {                 info = [NSLocalizedDescriptionKey: message as String]@@ -86,7 +87,7 @@ public struct KeychainStorage: KeyValueStorage {         ])          var result: AnyObject?-        try Self.check(SecItemCopyMatching(query, &result))+        try Self.check(SecItemCopyMatching(query, &result), ignoreNotFound: true)          return result as? Data     }@@ -96,7 +97,7 @@ public struct KeychainStorage: KeyValueStorage {         defer { lock.unlock() }          // remove old before setting new value-        try Self.check(SecItemDelete(makeQuery(forKey: key, [:])))+        try Self.check(SecItemDelete(makeQuery(forKey: key, [:])), ignoreNotFound: true)          guard let data = data else { return }