     
     public func setAllSynced() {
         let passwordEntities = fetchUnsyncedPasswords()
-        for passwordEntity in passwordEntities {
-            passwordEntity.synced = true
-        }
-        do {
-            if context.hasChanges {
-                try context.save()
-            }
-        } catch {
-            fatalError("ErrorSaving".localize(error))
+        if passwordEntities.count > 0 {
+            for passwordEntity in passwordEntities {
+                passwordEntity.synced = true
+            }
+            self.saveUpdatedContext()
         }
     }
     

            do {
                try privateMOC.save()
                self.context.performAndWait {
                    do {
                        try self.context.save()
                    } catch {
                        fatalError("FailureToSaveContext".localize(error))
                    }
                }
            } catch {
                fatalError("FailureToSaveContext".localize(error))

        for path in paths {
            let isDir = !path.hasSuffix(".gpg")
            if let passwordEntity = getPasswordEntity(by: path, isDir: isDir) {
                passwordEntity.synced = false
                parentPasswordEntity = passwordEntity
            } else {
                let passwordEntity = NSEntityDescription.insertNewObject(forEntityName: "PasswordEntity", into: self.context) as! PasswordEntity
                let pathURL = URL(string: path.stringByAddingPercentEncodingForRFC3986()!)!
                if isDir {
                    passwordEntity.name = pathURL.lastPathComponent
                } else {
                    passwordEntity.name = pathURL.deletingPathExtension().lastPathComponent
                }
                passwordEntity.path = path
                passwordEntity.parent = parentPasswordEntity
                passwordEntity.synced = false
                passwordEntity.isDir = isDir
                parentPasswordEntity = passwordEntity
            }
        }

        self.saveUpdatedContext()
        return parentPasswordEntity
    }
    
    public func add(password: Password) throws -> PasswordEntity? {
