Cleanup duplicated code (#678)
This commit is contained in:
parent
b0a971507f
commit
1e79e12593
2 changed files with 2 additions and 10 deletions
|
|
@ -113,14 +113,6 @@ public class PasswordStore {
|
||||||
fileManager.fileExists(atPath: Globals.repositoryURL.path)
|
fileManager.fileExists(atPath: Globals.repositoryURL.path)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func passwordExisted(password: Password) -> Bool {
|
|
||||||
PasswordEntity.exists(password: password, in: context)
|
|
||||||
}
|
|
||||||
|
|
||||||
public func getPasswordEntity(by path: String, isDir: Bool) -> PasswordEntity? {
|
|
||||||
PasswordEntity.fetch(by: path, isDir: isDir, in: context)
|
|
||||||
}
|
|
||||||
|
|
||||||
public func cloneRepository(
|
public func cloneRepository(
|
||||||
remoteRepoURL: URL,
|
remoteRepoURL: URL,
|
||||||
branchName: String,
|
branchName: String,
|
||||||
|
|
@ -236,7 +228,7 @@ public class PasswordStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func addPasswordEntities(password: Password) throws -> PasswordEntity? {
|
private func addPasswordEntities(password: Password) throws -> PasswordEntity? {
|
||||||
guard !passwordExisted(password: password) else {
|
guard !PasswordEntity.exists(password: password, in: context) else {
|
||||||
throw AppError.passwordDuplicated
|
throw AppError.passwordDuplicated
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ final class PasswordStoreTest: XCTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func decrypt(passwordStore: PasswordStore, path: String, passphrase _: String) throws -> Password {
|
private func decrypt(passwordStore: PasswordStore, path: String, passphrase _: String) throws -> Password {
|
||||||
let entity = passwordStore.getPasswordEntity(by: path, isDir: false)!
|
let entity = passwordStore.fetchPasswordEntity(with: path)!
|
||||||
return try passwordStore.decrypt(passwordEntity: entity, requestPGPKeyPassphrase: requestPGPKeyPassphrase)
|
return try passwordStore.decrypt(passwordEntity: entity, requestPGPKeyPassphrase: requestPGPKeyPassphrase)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue