Clone if password store directory is not existed

This commit is contained in:
Bob Sun 2017-02-27 17:30:33 +08:00
parent eff8d11c1e
commit 88bf3a0d18
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
2 changed files with 7 additions and 1 deletions

View file

@ -104,7 +104,8 @@ class SettingsTableViewController: UITableViewController {
Defaults[.gitRepositoryURL]!.absoluteString != gitRepostiroyURL ||
auth != Defaults[.gitRepositoryAuthenticationMethod] ||
username != Defaults[.gitRepositoryUsername] ||
password != PasswordStore.shared.gitRepositoryPassword {
password != PasswordStore.shared.gitRepositoryPassword ||
PasswordStore.shared.exists() == false {
SVProgressHUD.setDefaultMaskType(.black)
SVProgressHUD.setDefaultStyle(.light)

View file

@ -180,6 +180,11 @@ class PasswordStore {
return pgp.getKeysOf(.secret)[0]
}
func exists() -> Bool {
let fm = FileManager()
return fm.fileExists(atPath: Globals.repositoryPath)
}
func initPGP(pgpPublicKeyURL: URL, pgpPublicKeyLocalPath: String, pgpPrivateKeyURL: URL, pgpPrivateKeyLocalPath: String) throws {
let pgpPublicData = try Data(contentsOf: pgpPublicKeyURL)
try pgpPublicData.write(to: URL(fileURLWithPath: pgpPublicKeyLocalPath), options: .atomic)