Skip to content

Commit

Permalink
Cleanup duplicated code
Browse files Browse the repository at this point in the history
  • Loading branch information
mssun committed Feb 8, 2025
1 parent b0a9715 commit adb0124
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
10 changes: 1 addition & 9 deletions passKit/Models/PasswordStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,6 @@ public class PasswordStore {
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(
remoteRepoURL: URL,
branchName: String,
Expand Down Expand Up @@ -236,7 +228,7 @@ public class PasswordStore {
}

private func addPasswordEntities(password: Password) throws -> PasswordEntity? {
guard !passwordExisted(password: password) else {
guard !PasswordEntity.exists(password: password, in: context) else {
throw AppError.passwordDuplicated
}

Expand Down
2 changes: 1 addition & 1 deletion passKitTests/Models/PasswordStoreTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ final class PasswordStoreTest: XCTestCase {
}

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)
}
}

0 comments on commit adb0124

Please sign in to comment.