34 lines
1.1 KiB
Swift
34 lines
1.1 KiB
Swift
import Foundation
|
|
|
|
/// Removes search configuration that became both unused and unreachable when
|
|
/// ScrubberKit replaced the selectable Web Search backends.
|
|
@MainActor
|
|
enum LegacyWebSearchSettings {
|
|
static let backendKey = "search.backend"
|
|
static let baseURLKey = "search.baseURL"
|
|
static let credentialReferenceKey = "search.credentialRef"
|
|
|
|
static func remove(
|
|
defaults: UserDefaults = .standard,
|
|
deleteSecret: (String) throws -> Void
|
|
) {
|
|
defaults.removeObject(forKey: backendKey)
|
|
defaults.removeObject(forKey: baseURLKey)
|
|
|
|
guard let reference = defaults.string(forKey: credentialReferenceKey),
|
|
!reference.isEmpty
|
|
else {
|
|
defaults.removeObject(forKey: credentialReferenceKey)
|
|
return
|
|
}
|
|
|
|
do {
|
|
try deleteSecret(reference)
|
|
defaults.removeObject(forKey: credentialReferenceKey)
|
|
} catch {
|
|
// Keep the reference so the next launch can retry. Removing it on
|
|
// failure would strand an unreachable Keychain item permanently.
|
|
}
|
|
}
|
|
}
|