Skip to content

armgit / ente

Public Imported from GitHub
0

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

Fix forceUpload to shared albums (#1572)

Neeraj Guptaf023022fffa4
diff --git a/lib/utils/file_uploader.dart b/lib/utils/file_uploader.dart
index 54d4f3ddd2..97ea61d834 100644
--- a/lib/utils/file_uploader.dart
+++ b/lib/utils/file_uploader.dart
@@ -68,6 +68,11 @@ class FileUploader {
late ProcessType _processType;
late bool _isBackground;
late SharedPreferences _prefs;
+ // _hasInitiatedForceUpload is used to track if user attempted force upload
+ // where files are uploaded directly (without adding them to DB). In such
+ // cases, we don't want to clear the stale upload files. See #removeStaleFiles
+ // as it can result in clearing files which are still being force uploaded.
+ bool _hasInitiatedForceUpload = false;
FileUploader._privateConstructor() {
Bus.instance.on<SubscriptionPurchasedEvent>().listen((event) {
@@ -285,6 +290,12 @@ class FileUploader {
}
Future<void> removeStaleFiles() async {
+ if (_hasInitiatedForceUpload) {
+ _logger.info(
+ "Force upload was initiated, skipping stale file cleanup",
+ );
+ return;
+ }
try {
final String dir = Configuration.instance.getTempDirectory();
// delete all files in the temp directory that start with upload_ and
@@ -324,6 +335,7 @@ class FileUploader {
}
Future<EnteFile> forceUpload(EnteFile file, int collectionID) async {
+ _hasInitiatedForceUpload = true;
return _tryToUpload(file, collectionID, true);
}