Ver Fonte

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

Vishnu Mohandas há 4 anos atrás
pai
commit
8334ec809e
1 ficheiros alterados com 6 adições e 6 exclusões
  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);
           }