Delete key files after migrating them to Keychain

This commit is contained in:
Danny Moesch 2019-06-26 22:57:06 +02:00 committed by Mingshen Sun
parent 441a7f1e9b
commit f0003227d5

View file

@ -191,11 +191,18 @@ public class PasswordStore {
}
private func importExistingKeysIntoKeychain() {
do {
if let publicKey = fm.contents(atPath: Globals.pgpPublicKeyPath) {
AppKeychain.add(data: publicKey, for: PGPKeyType.PUBLIC.rawValue)
try fm.removeItem(atPath: Globals.pgpPublicKeyPath)
}
if let privateKey = fm.contents(atPath: Globals.pgpPrivateKeyPath) {
AppKeychain.add(data: privateKey, for: PGPKeyType.PRIVATE.rawValue)
try fm.removeItem(atPath: Globals.pgpPrivateKeyPath)
}
SharedDefaults[.pgpKeySource] = "file"
} catch {
print("MigrationError".localize(error))
}
}