File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Sources/ComposableStorageCrypto Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ public struct KeychainStorage<Item: Storable>: ThrowingStorage {
5353 public func item( matching label: String ) throws -> Item ? {
5454 try keychain. container ( for: label)
5555 . fetch ( )
56- . flatMap { try Item . decoding ( $0) }
56+ . flatMap { try ? Item . decoding ( $0) }
5757 }
5858
5959 /// Return all stored `Item`s.
@@ -84,13 +84,17 @@ public struct KeychainStorage<Item: Storable>: ThrowingStorage {
8484 public func discard( _ label: String ) throws -> Item ? {
8585 try keychain. container ( for: label)
8686 . drop ( )
87- . flatMap { try Item . decoding ( $0) }
87+ . flatMap { try ? Item . decoding ( $0) }
8888 }
8989
9090 /// Empty storage.
9191 ///
9292 /// - throws: Some `Error`.
9393 public func empty( ) throws {
9494 try keychain. empty ( )
95+ // If it's not empty just manually delete them all.
96+ let keys = try keychain. keys ( )
97+ guard !keys. isEmpty else { return }
98+ keys. forEach { try ? keychain. container ( for: $0) . drop ( ) }
9599 }
96100}
You can’t perform that action at this time.
0 commit comments