π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob] Don't delete encrypt file in case of upload error
Neeraj Gupta7cbeeacd827d
diff --git a/mobile/lib/module/upload/service/multipart.dart b/mobile/lib/module/upload/service/multipart.dartindex 222c5d9767..1cf4f092b7 100644--- a/mobile/lib/module/upload/service/multipart.dart+++ b/mobile/lib/module/upload/service/multipart.dart@@ -193,9 +193,6 @@ class MultiPartUploader {"Uploading part ${i + 1} / $partsLength of size $fileSize bytes (total size $encFileLength).",);if (kDebugMode && count > 1) {- // This is to catch any bugs in the code at future point of time.- // Due to lack of proper integrations tests, this act as a way to- // catch any bug early. :sed:throw Exception('In debug mode, only one part will be uploaded at a time.',);diff --git a/mobile/lib/utils/file_uploader.dart b/mobile/lib/utils/file_uploader.dartindex 1610468315..fe374386a0 100644--- a/mobile/lib/utils/file_uploader.dart+++ b/mobile/lib/utils/file_uploader.dart@@ -439,6 +439,7 @@ class FileUploader {}final String lockKey = file.localID!;+ bool _isMultipartUpload = false;try {await _uploadLocks.acquireLock(@@ -524,6 +525,8 @@ class FileUploader {// that we'll have to reupload as the nonce is lostif (multipartEntryExists) {if (!encryptedFileExists) {+ _logger+ .warning('encrypted file not found for multipart upload entry');await _uploadLocks.deleteMultipartTrack(lockKey);multipartEntryExists = false;multipartEncryptionResult = null;@@ -577,6 +580,7 @@ class FileUploader {final fileUploadURL = await _getUploadURL();fileObjectKey = await _putFile(fileUploadURL, encryptedFile);} else {+ _isMultipartUpload = true;dev.log("Init multipartUpload $multipartEntryExists", name: "Uploader");if (multipartEntryExists) {fileObjectKey = await _multiPartUploader.putExistingMultipartFile(@@ -732,6 +736,7 @@ class FileUploader {encryptedFilePath,encryptedThumbnailPath,lockKey: lockKey,+ isMultiPartUpload: _isMultipartUpload,);}}@@ -876,20 +881,27 @@ class FileUploader {String encryptedFilePath,String encryptedThumbnailPath, {required String lockKey,+ bool isMultiPartUpload = false,}) async {if (mediaUploadData != null && mediaUploadData.sourceFile != null) {// delete the file from app's internal cache if it was copied to app// for upload. On iOS, only remove the file from photo_manager/app cache// when upload is either completed or there's a tempFailure// Shared Media should only be cleared when the upload- // succeeds.+ // succeeds.Haif ((Platform.isIOS && (uploadCompleted || uploadHardFailure)) ||(uploadCompleted && file.isSharedMediaToAppSandbox)) {await mediaUploadData.sourceFile?.delete();}}if (File(encryptedFilePath).existsSync()) {- await File(encryptedFilePath).delete();+ if (isMultiPartUpload && !uploadCompleted) {+ _logger.fine(+ "skip delete for multipart encrypted file $encryptedFilePath");+ } else {+ _logger.fine("deleting encrypted file $encryptedFilePath");+ await File(encryptedFilePath).delete();+ }}if (File(encryptedThumbnailPath).existsSync()) {await File(encryptedThumbnailPath).delete();