Explorar el Código

Skip parsing files that are already in sync

Vishnu Mohandas hace 4 años
padre
commit
b92023ad5c
Se han modificado 2 ficheros con 22 adiciones y 1 borrados
  1. 16 0
      lib/db/files_db.dart
  2. 6 1
      lib/utils/file_downloader.dart

+ 16 - 0
lib/db/files_db.dart

@@ -126,6 +126,22 @@ class FilesDB {
     return _convertToFiles(results)[0];
   }
 
+  Future<File> getUploadedFile(int uploadedID, int collectionID) async {
+    final db = await instance.database;
+    final results = await db.query(
+      table,
+      where: '$columnUploadedFileID = ? AND $columnCollectionID = ?',
+      whereArgs: [
+        uploadedID,
+        collectionID,
+      ],
+    );
+    if (results.isEmpty) {
+      return null;
+    }
+    return _convertToFiles(results)[0];
+  }
+
   Future<List<File>> getDeduplicatedFiles() async {
     _logger.info("Getting files for collection");
     final db = await instance.database;

+ 6 - 1
lib/utils/file_downloader.dart

@@ -47,8 +47,13 @@ class DiffFetcher {
                     CollectionUpdatedEvent(collectionID: file.collectionID));
                 continue;
               }
-              file.ownerID = item["ownerID"];
               file.updationTime = item["updationTime"];
+              final existingFile = await FilesDB.instance
+                  .getUploadedFile(file.uploadedFileID, file.collectionID);
+              if (existingFile.updationTime == file.updationTime) {
+                continue;
+              }
+              file.ownerID = item["ownerID"];
               file.isEncrypted = true;
               file.encryptedKey = item["encryptedKey"];
               file.keyDecryptionNonce = item["keyDecryptionNonce"];