Cleanup code of error handling
This commit is contained in:
parent
9a3131943f
commit
2bfb36c527
8 changed files with 17 additions and 43 deletions
|
|
@ -13,12 +13,7 @@ import KeychainAccess
|
|||
public class Utils {
|
||||
public static func getPasswordFromKeychain(name: String) -> String? {
|
||||
let keychain = Keychain(service: Globals.bundleIdentifier, accessGroup: Globals.groupIdentifier)
|
||||
do {
|
||||
return try keychain.getString(name)
|
||||
} catch {
|
||||
print(error)
|
||||
}
|
||||
return nil
|
||||
return (try? keychain.getString(name)) ?? nil
|
||||
}
|
||||
|
||||
public static func addPasswordToKeychain(name: String, password: String?) {
|
||||
|
|
@ -28,20 +23,12 @@ public class Utils {
|
|||
|
||||
public static func removeKeychain(name: String) {
|
||||
let keychain = Keychain(service: Globals.bundleIdentifier, accessGroup: Globals.groupIdentifier)
|
||||
do {
|
||||
try keychain.remove(name)
|
||||
} catch {
|
||||
print(error)
|
||||
}
|
||||
try? keychain.remove(name)
|
||||
}
|
||||
|
||||
public static func removeAllKeychain() {
|
||||
let keychain = Keychain(service: Globals.bundleIdentifier, accessGroup: Globals.groupIdentifier)
|
||||
do {
|
||||
try keychain.removeAll()
|
||||
} catch {
|
||||
print(error)
|
||||
}
|
||||
try? keychain.removeAll()
|
||||
}
|
||||
public static func copyToPasteboard(textToCopy: String?) {
|
||||
guard textToCopy != nil else {
|
||||
|
|
|
|||
|
|
@ -528,10 +528,6 @@ public class PasswordStore {
|
|||
private func gitMv(from: String, to: String) throws {
|
||||
let fromURL = storeURL.appendingPathComponent(from)
|
||||
let toURL = storeURL.appendingPathComponent(to)
|
||||
guard fm.fileExists(atPath: fromURL.path) else {
|
||||
print("\(from) not exist")
|
||||
return
|
||||
}
|
||||
try fm.moveItem(at: fromURL, to: toURL)
|
||||
try gitAdd(path: to)
|
||||
try gitRm(path: from)
|
||||
|
|
@ -872,20 +868,12 @@ public class PasswordStore {
|
|||
}
|
||||
}
|
||||
|
||||
public func gitSSHKeyImportFromFileSharing() {
|
||||
do {
|
||||
try fm.moveItem(atPath: Globals.iTunesFileSharingSSHPrivate, toPath: Globals.gitSSHPrivateKeyPath)
|
||||
} catch {
|
||||
print(error)
|
||||
}
|
||||
public func gitSSHKeyImportFromFileSharing() throws {
|
||||
try fm.moveItem(atPath: Globals.iTunesFileSharingSSHPrivate, toPath: Globals.gitSSHPrivateKeyPath)
|
||||
}
|
||||
|
||||
public func pgpKeyImportFromFileSharing() {
|
||||
do {
|
||||
try fm.moveItem(atPath: Globals.iTunesFileSharingPGPPublic, toPath: Globals.pgpPublicKeyPath)
|
||||
try fm.moveItem(atPath: Globals.iTunesFileSharingPGPPrivate, toPath: Globals.pgpPrivateKeyPath)
|
||||
} catch {
|
||||
print(error)
|
||||
}
|
||||
public func pgpKeyImportFromFileSharing() throws {
|
||||
try fm.moveItem(atPath: Globals.iTunesFileSharingPGPPublic, toPath: Globals.pgpPublicKeyPath)
|
||||
try fm.moveItem(atPath: Globals.iTunesFileSharingPGPPrivate, toPath: Globals.pgpPrivateKeyPath)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue