Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Fixes

AmanRajSinghMouryae2d102c01ae4
diff --git a/mobile/apps/locker/lib/services/collections/collections_service.dart b/mobile/apps/locker/lib/services/collections/collections_service.dart
index 0ebc379bab..b51aa1fdb0 100644
--- a/mobile/apps/locker/lib/services/collections/collections_service.dart
+++ b/mobile/apps/locker/lib/services/collections/collections_service.dart
@@ -102,7 +102,7 @@ class CollectionService {
await _setFirstSyncCompleted();
}
- final List<Future> fileFutures = [];
+ final List<Future<bool>> fileFutures = [];
for (final collection in updatedCollections) {
if (collection.isDeleted) {
continue;
@@ -126,15 +126,23 @@ class CollectionService {
collection.id,
diff.latestUpdatedAtTime,
);
+ return true;
}).catchError((e) {
_logger.severe(
"Failed to fetch files for collection ${collection.id}: $e",
);
+ return false;
}),
);
}
- await Future.wait(fileFutures);
- await OfflineFilesService.instance.cleanupInactiveOfflineFiles();
+ final fileSyncResults = await Future.wait(fileFutures);
+ if (fileSyncResults.every((didSync) => didSync)) {
+ await OfflineFilesService.instance.cleanupInactiveOfflineFiles();
+ } else {
+ _logger.warning(
+ "Skipping offline stale cleanup because one or more collection syncs failed",
+ );
+ }
if (updatedCollections.isNotEmpty) {
Bus.instance.fire(CollectionsUpdatedEvent('sync'));
}
diff --git a/mobile/apps/locker/lib/services/files/download/file_downloader.dart b/mobile/apps/locker/lib/services/files/download/file_downloader.dart
index 8452efc277..96458f2d99 100644
--- a/mobile/apps/locker/lib/services/files/download/file_downloader.dart
+++ b/mobile/apps/locker/lib/services/files/download/file_downloader.dart
@@ -145,7 +145,8 @@ Future<File?> openFile(
? _getTemporaryDecryptedFilePath(file)
: getCachedDecryptedFilePath(file);
final File decryptedFile = File(decryptedFilePath);
- final int sizeInBytes = file.fileSize ?? await offlineEncryptedFile.length();
+ final int sizeInBytes =
+ file.fileSize ?? await offlineEncryptedFile.length();
try {
if (await decryptedFile.exists()) {
@@ -187,20 +188,6 @@ Future<File?> openFile(
s,
);
}
-
- if (file.uploadedFileID != null) {
- try {
- await removeOfflineFileCopiesFromDisk(
- [file.uploadedFileID!],
- removeWorkingCopies: false,
- );
- await LockerDB.instance.setFilesMarkedOffline(
- [file.uploadedFileID!],
- false,
- );
- } catch (_) {}
- }
-
return downloadAndDecrypt(
file,
fileKey,