From ebb3566616c3ebd0cc59ac8bd97d4d6e35bcd0f2 Mon Sep 17 00:00:00 2001 From: Yishi Lin Date: Wed, 15 May 2019 01:09:58 +0800 Subject: [PATCH] Cleanup old migration codes --- passKit/Models/PasswordStore.swift | 50 ------------------------------ 1 file changed, 50 deletions(-) diff --git a/passKit/Models/PasswordStore.swift b/passKit/Models/PasswordStore.swift index eae2872..907217c 100644 --- a/passKit/Models/PasswordStore.swift +++ b/passKit/Models/PasswordStore.swift @@ -121,10 +121,6 @@ public class PasswordStore { } private init() { - // File migration to group - migrateIfNeeded() - backwardCompatibility() - do { if fm.fileExists(atPath: storeURL.path) { try storeRepository = GTRepository.init(url: storeURL) @@ -135,52 +131,6 @@ public class PasswordStore { } } - private func migrateIfNeeded() { - // migrate happens only if the repository was cloned and pgp keys were set up using earlier versions - let needMigration = !pgpKeyExists() && !gitSSHKeyExists() && !fm.fileExists(atPath: Globals.repositoryPath) && fm.fileExists(atPath: Globals.repositoryPathLegacy) - guard needMigration == true else { - return - } - - do { - // migrate Defaults - let userDefaults = UserDefaults() - for key in Defaults.dictionaryRepresentation().keys { - if SharedDefaults.value(forKey: key) == nil { - SharedDefaults.setValue(userDefaults.value(forKey: key), forKey: key) - } - } - - // migrate files - try fm.createDirectory(atPath: Globals.documentPath, withIntermediateDirectories: true, attributes: nil) - try fm.createDirectory(atPath: Globals.libraryPath, withIntermediateDirectories: true, attributes: nil) - if fm.fileExists(atPath: Globals.pgpPublicKeyPathLegacy) { - try fm.moveItem(atPath: Globals.pgpPublicKeyPathLegacy, toPath: Globals.pgpPublicKeyPath) - } - if fm.fileExists(atPath: Globals.pgpPrivateKeyPathLegacy) { - try fm.moveItem(atPath: Globals.pgpPrivateKeyPathLegacy, toPath: Globals.pgpPrivateKeyPath) - } - if fm.fileExists(atPath: Globals.gitSSHPrivateKeyPathLegacy) { - try fm.moveItem(atPath: Globals.gitSSHPrivateKeyPathLegacy, toPath: Globals.gitSSHPrivateKeyPath) - } - try fm.moveItem(atPath: Globals.repositoryPathLegacy, toPath: Globals.repositoryPath) - } catch { - print("MigrationError".localize(error)) - } - updatePasswordEntityCoreData() - } - - private func backwardCompatibility() { - // For the newly-introduced isRememberGitCredentialPassphraseOn (20171008) - if (self.gitPassword != nil || self.gitSSHPrivateKeyPassphrase != nil) && SharedDefaults[.isRememberGitCredentialPassphraseOn] == false { - SharedDefaults[.isRememberGitCredentialPassphraseOn] = true - } - // For the renamed isRememberPGPPassphraseOn (20171008) - if self.pgpKeyPassphrase != nil && SharedDefaults[.isRememberPGPPassphraseOn] == false { - SharedDefaults[.isRememberPGPPassphraseOn] = true - } - } - enum SSHKeyType { case `public`, secret }