Cleanup old migration codes
This commit is contained in:
parent
04b451874d
commit
ebb3566616
1 changed files with 0 additions and 50 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue