fix deleting directory
this used to corrupt the local state (password entities remained in DB but files/dirs were removed from git and disk)
This commit is contained in:
parent
4405b7fe3d
commit
2c8d27df69
4 changed files with 24 additions and 0 deletions
|
|
@ -15,6 +15,7 @@ public enum AppError: Error, Equatable {
|
|||
case keyImport
|
||||
case readingFile(fileName: String)
|
||||
case passwordDuplicated
|
||||
case cannotDeleteDirectory
|
||||
case gitReset
|
||||
case gitCommit
|
||||
case gitCreateSignature
|
||||
|
|
|
|||
|
|
@ -273,6 +273,10 @@ public class PasswordStore {
|
|||
}
|
||||
|
||||
public func delete(passwordEntity: PasswordEntity) throws {
|
||||
if passwordEntity.isDir {
|
||||
throw AppError.cannotDeleteDirectory
|
||||
}
|
||||
|
||||
let deletedFileURL = passwordEntity.fileURL(in: storeURL)
|
||||
let deletedFilePath = passwordEntity.path
|
||||
try gitRm(path: passwordEntity.path)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue