Something went wrong. Try again.
macOS menu bar app for Restic
Something went wrong. Try again.
1.6 kB · 40 lines
Swift
at main
1234567891011121314151617181920212223242526272829303132333435363738394041import Foundationimport SnapshotKit
/// The stored secrets can't be read unattended, and what would fix that.////// Both faults come back from the Keychain as one status and are found the same/// way — a read that refuses to raise a dialog — but the dialog that fixes them/// asks different things: Always Allow for a build that isn't on the access/// list, the login password for a locked keychain. The remedy says which, so/// the button offering it can too.public struct KeychainProblem: Equatable, Sendable { public enum Remedy: Equatable, Sendable { /// The Always Allow prompt, which adds this build to the item's access /// list for good. case authorise /// The unlock prompt for the login keychain. case unlock }
public var message: String public var remedy: Remedy
init(_ error: any Error) { switch error as? KeychainError { case .needsAuthorisation(_, interactionAllowed: false): // The error's own words are for a run that has just failed; here // nothing has run, and the fix is the button beside this. message = "This build of Snapshot isn't on the repository password's access list — " + "a rebuilt app never is. Scheduled backups will fail until it's authorised." remedy = .authorise case .keychainLocked: message = "\(error)" remedy = .unlock default: message = "\(error)" remedy = .authorise } }}