Skip to content

Commit 1526787

Browse files
committed
Merge development into main
2 parents be234e0 + 37567d0 commit 1526787

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Sources/ComposableStorageCrypto/KeychainStorage.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)