瀏覽代碼

Make sure that the right files are updated while applying a diff

Vishnu Mohandas 4 年之前
父節點
當前提交
8334ec809e
共有 1 個文件被更改,包括 6 次插入6 次删除
  1. 6 6
      lib/services/sync_service.dart

+ 6 - 6
lib/services/sync_service.dart

@@ -231,17 +231,17 @@ class SyncService {
           file.generatedID = existingFiles[0].generatedID;
           await _db.update(file);
         } else {
-          bool wasUpdatedInExistingCollection = false;
+          bool foundMatchingCollection = false;
           for (final existingFile in existingFiles) {
-            if (file.collectionID == existingFile.collectionID) {
+            if (file.collectionID == existingFile.collectionID &&
+                file.uploadedFileID == existingFile.uploadedFileID) {
+              foundMatchingCollection = true;
               file.generatedID = existingFile.generatedID;
-              wasUpdatedInExistingCollection = true;
+              await _db.update(file);
               break;
             }
           }
-          if (wasUpdatedInExistingCollection) {
-            await _db.update(file);
-          } else {
+          if (!foundMatchingCollection) {
             // Added to a new collection
             await _db.insert(file);
           }