Browse Source

Add a different name for files being uploaded in the background

Vishnu Mohandas 4 years ago
parent
commit
d2fd2004f4
1 changed files with 11 additions and 4 deletions
  1. 11 4
      lib/utils/file_uploader.dart

+ 11 - 4
lib/utils/file_uploader.dart

@@ -44,6 +44,7 @@ class FileUploader {
 
   int _currentlyUploading = 0;
   ProcessType _processType;
+  bool _isBackground;
   SharedPreferences _prefs;
 
   FileUploader._privateConstructor() {
@@ -55,6 +56,7 @@ class FileUploader {
 
   Future<void> init(bool isBackground) async {
     _prefs = await SharedPreferences.getInstance();
+    _isBackground = isBackground;
     _processType =
         isBackground ? ProcessType.background : ProcessType.foreground;
     final currentTime = DateTime.now().microsecondsSinceEpoch;
@@ -217,10 +219,15 @@ class FileUploader {
     }
 
     final tempDirectory = Configuration.instance.getTempDirectory();
-    final encryptedFilePath =
-        tempDirectory + file.generatedID.toString() + ".encrypted";
-    final encryptedThumbnailPath =
-        tempDirectory + file.generatedID.toString() + "_thumbnail.encrypted";
+    final encryptedFilePath = tempDirectory +
+        file.generatedID.toString() +
+        (_isBackground ? "_bg" : "") +
+        ".encrypted";
+    final encryptedThumbnailPath = tempDirectory +
+        file.generatedID.toString() +
+        "_thumbnail" +
+        (_isBackground ? "_bg" : "") +
+        ".encrypted";
     var sourceFile;
 
     try {