π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Remove file entry for files that are already queued
Neeraj Guptab58aeddeba45
diff --git a/mobile/apps/photos/lib/db/files_db.dart b/mobile/apps/photos/lib/db/files_db.dartindex f8900f8912..3150dbc3b6 100644--- a/mobile/apps/photos/lib/db/files_db.dart+++ b/mobile/apps/photos/lib/db/files_db.dart@@ -979,6 +979,29 @@ class FilesDB with SqlDbBase {return result;}+ // remove references for local files which are either already uploaded+ // or queued for upload but not yet uploaded+ Future<int> removeQueuedLocalFiles(Set<String> localIDs) async {+ final db = await instance.sqliteAsyncDB;+ final inParam = localIDs.map((id) => "'$id'").join(',');+ final r = await db.execute(+ '''+ DELETE FROM $filesTable+ WHERE $columnLocalID IN ($inParam) and (collectionID IS NULL || collectionID = -1)+ and ($columnUploadedFileID IS NULL OR $columnUploadedFileID = -1);+ ''',+ );+ if (r.isNotEmpty) {+ _logger.warning(+ "Removed ${r.length} potential dups for already queued local files",+ );+ } else {+ _logger.finest("No duplicate id found for queued/uploaded files");+ }++ return r.length;+ }+Future<Set<String>> getLocalFileIDsForCollection(int collectionID) async {final db = await instance.sqliteAsyncDB;final rows = await db.getAll(diff --git a/mobile/apps/photos/lib/services/sync/remote_sync_service.dart b/mobile/apps/photos/lib/services/sync/remote_sync_service.dartindex d4523b27d0..d0e995a438 100644--- a/mobile/apps/photos/lib/services/sync/remote_sync_service.dart+++ b/mobile/apps/photos/lib/services/sync/remote_sync_service.dart@@ -371,6 +371,9 @@ class RemoteSyncService {final Set<String> alreadyClaimedLocalIDs =await _db.getLocalIDsMarkedForOrAlreadyUploaded(ownerID);localIDsToSync.removeAll(alreadyClaimedLocalIDs);+ if (alreadyClaimedLocalIDs.isNotEmpty) {+ await _db.removeQueuedLocalFiles(alreadyClaimedLocalIDs);+ }}if (localIDsToSync.isEmpty) {