From adff0c11428a11e7bdfc83024f258956346668ab Mon Sep 17 00:00:00 2001 From: Danny Moesch Date: Wed, 15 May 2019 22:49:46 +0200 Subject: [PATCH] Fix #258: Remove existing key files before moving new ones to the same location --- passKit/Models/PasswordStore.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/passKit/Models/PasswordStore.swift b/passKit/Models/PasswordStore.swift index 934d1f3..21685d9 100644 --- a/passKit/Models/PasswordStore.swift +++ b/passKit/Models/PasswordStore.swift @@ -838,10 +838,17 @@ public class PasswordStore { } public func gitSSHKeyImportFromFileSharing() throws { + if gitSSHKeyExists() { + try fm.removeItem(atPath: Globals.gitSSHPrivateKeyPath) + } try fm.moveItem(atPath: Globals.iTunesFileSharingSSHPrivate, toPath: Globals.gitSSHPrivateKeyPath) } public func pgpKeyImportFromFileSharing() throws { + if pgpKeyExists() { + try fm.removeItem(atPath: Globals.pgpPublicKeyPath) + try fm.removeItem(atPath: Globals.pgpPrivateKeyPath) + } try fm.moveItem(atPath: Globals.iTunesFileSharingPGPPublic, toPath: Globals.pgpPublicKeyPath) try fm.moveItem(atPath: Globals.iTunesFileSharingPGPPrivate, toPath: Globals.pgpPrivateKeyPath) }