         return true
     }
     
-    func getPasswordEntity(by path: String) -> PasswordEntity? {
+    func getPasswordEntity(by path: String, isDir: Bool) -> PasswordEntity? {
         let passwordEntityFetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: "PasswordEntity")
         do {
-            passwordEntityFetchRequest.predicate = NSPredicate(format: "path = %@", path)
+            passwordEntityFetchRequest.predicate = NSPredicate(format: "path = %@ and isDir = %@", path, isDir.description)
             return try context.fetch(passwordEntityFetchRequest).first as? PasswordEntity
         } catch {
             fatalError("Failed to fetch password entities: \(error)")

        paths.reverse()
        var parentPasswordEntity: PasswordEntity? = nil
        for path in paths {
            if let passwordEntity = getPasswordEntity(by: path) {
                parentPasswordEntity = passwordEntity
            } else {
                if path.hasSuffix(".gpg") {
                    return insertPasswordEntity(name: URL(string: path.stringByAddingPercentEncodingForRFC3986()!)!.deletingPathExtension().lastPathComponent, path: path, parent: parentPasswordEntity, synced: false, isDir: false)
                } else {
                    parentPasswordEntity = insertPasswordEntity(name: URL(string: path.stringByAddingPercentEncodingForRFC3986()!)!.lastPathComponent, path: path, parent: parentPasswordEntity, synced: false, isDir: true)

    
    private func gitRm(path: String) throws {
        if let repo = storeRepository {
            if FileManager.default.fileExists(atPath: storeURL.appendingPathComponent(path).path) {
                try FileManager.default.removeItem(at: storeURL.appendingPathComponent(path))
            }
            try repo.index().removeFile(path)
            try repo.index().write()
        }
