Skip to content

Commit 1e79e12

Browse files
authored
Cleanup duplicated code (#678)
1 parent b0a9715 commit 1e79e12

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

passKit/Models/PasswordStore.swift

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,6 @@ public class PasswordStore {
113113
fileManager.fileExists(atPath: Globals.repositoryURL.path)
114114
}
115115

116-
public func passwordExisted(password: Password) -> Bool {
117-
PasswordEntity.exists(password: password, in: context)
118-
}
119-
120-
public func getPasswordEntity(by path: String, isDir: Bool) -> PasswordEntity? {
121-
PasswordEntity.fetch(by: path, isDir: isDir, in: context)
122-
}
123-
124116
public func cloneRepository(
125117
remoteRepoURL: URL,
126118
branchName: String,
@@ -236,7 +228,7 @@ public class PasswordStore {
236228
}
237229

238230
private func addPasswordEntities(password: Password) throws -> PasswordEntity? {
239-
guard !passwordExisted(password: password) else {
231+
guard !PasswordEntity.exists(password: password, in: context) else {
240232
throw AppError.passwordDuplicated
241233
}
242234

passKitTests/Models/PasswordStoreTest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ final class PasswordStoreTest: XCTestCase {
5353
}
5454

5555
private func decrypt(passwordStore: PasswordStore, path: String, passphrase _: String) throws -> Password {
56-
let entity = passwordStore.getPasswordEntity(by: path, isDir: false)!
56+
let entity = passwordStore.fetchPasswordEntity(with: path)!
5757
return try passwordStore.decrypt(passwordEntity: entity, requestPGPKeyPassphrase: requestPGPKeyPassphrase)
5858
}
5959
}

0 commit comments

Comments
 (0)