Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob] Clean up stale upload files inside uploader

Neeraj Gupta220e80e46759
diff --git a/mobile/lib/core/configuration.dart b/mobile/lib/core/configuration.dart
index 370597d1b3..334da4af94 100644
--- a/mobile/lib/core/configuration.dart
+++ b/mobile/lib/core/configuration.dart
@@ -155,7 +155,8 @@ class Configuration {
}
await _preferences.setInt(lastTempFolderClearTimeKey, currentTime);
_logger.info(
- "Cleared temp folder except $skippedTempUploadFiles upload files");
+ "Cleared temp folder except $skippedTempUploadFiles upload files",
+ );
} else {
_logger.info("Skipping temp folder clear");
}
diff --git a/mobile/lib/utils/file_uploader.dart b/mobile/lib/utils/file_uploader.dart
index 5dc11b1665..0ba23cacd7 100644
--- a/mobile/lib/utils/file_uploader.dart
+++ b/mobile/lib/utils/file_uploader.dart
@@ -52,6 +52,7 @@ class FileUploader {
static const kBlockedUploadsPollFrequency = Duration(seconds: 2);
static const kFileUploadTimeout = Duration(minutes: 50);
static const k20MBStorageBuffer = 20 * 1024 * 1024;
+ static const _lastStaleFileCleanupTime = "lastStaleFileCleanupTime";
final _logger = Logger("FileUploader");
final _dio = NetworkClient.instance.getDio();
@@ -121,6 +122,11 @@ class FileUploader {
UploadLocksDB.instance,
flagService,
);
+ if (currentTime - (_prefs.getInt(_lastStaleFileCleanupTime) ?? 0) >
+ tempDirCleanUpInterval) {
+ await removeStaleFiles();
+ await _prefs.setInt(_lastStaleFileCleanupTime, currentTime);
+ }
Bus.instance.on<LocalPhotosUpdatedEvent>().listen((event) {
if (event.type == EventType.deletedFromDevice ||
event.type == EventType.deletedFromEverywhere) {