π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Fix: Treat sandbox file as unique file during upload
Neeraj Guptafa33a1afd95a
diff --git a/mobile/lib/utils/file_uploader.dart b/mobile/lib/utils/file_uploader.dartindex 14e4361798..6d85368fe2 100644--- a/mobile/lib/utils/file_uploader.dart+++ b/mobile/lib/utils/file_uploader.dart@@ -907,12 +907,15 @@ class FileUploader {files. if the link is successful, it returns true otherwise false.When false, we should go ahead and re-upload or update the file.It performs following checks:- a) Uploaded file with same localID and destination collection. Delete the- fileToUpload entry+ a) Target file with same localID and destination collection exists. Delete the+ fileToUpload entry. If target file is sandbox file, then we skip localID match+ check.b) Uploaded file in any collection but with missing localID.Update the localID for uploadedFile and delete the fileToUpload entryc) A uploaded file exist with same localID but in a different collection.- Add a symlink in the destination collection and update the fileToUpload+ Add a symlink in the destination collection and update the fileToUpload.+ If target file is sandbox file, then we skip localID match+ check.d) File already exists but different localID. Re-uploadIn case the existing files already have local identifier, which isdifferent from the {fileToUpload}, then most probably device has@@ -931,6 +934,7 @@ class FileUploader {);return Tuple2(false, fileToUpload);}+ final bool isSandBoxFile = fileToUpload.isSharedMediaToAppSandbox;final List<EnteFile> existingUploadedFiles =await FilesDB.instance.getUploadedFilesWithHashes(@@ -947,12 +951,13 @@ class FileUploader {final EnteFile? sameLocalSameCollection =existingUploadedFiles.firstWhereOrNull((e) =>- e.collectionID == toCollectionID && e.localID == fileToUpload.localID,+ e.collectionID == toCollectionID &&+ (e.localID == fileToUpload.localID || isSandBoxFile),);if (sameLocalSameCollection != null) {_logger.fine(- "sameLocalSameCollection: \n toUpload ${fileToUpload.tag} "- "\n existing: ${sameLocalSameCollection.tag}",+ "sameLocalSameCollection: toUpload ${fileToUpload.tag} "+ "existing: ${sameLocalSameCollection.tag} $isSandBoxFile",);// should delete the fileToUploadEntryif (fileToUpload.generatedID != null) {@@ -1005,12 +1010,13 @@ class FileUploader {final EnteFile? fileExistsButDifferentCollection =existingUploadedFiles.firstWhereOrNull((e) =>- e.collectionID != toCollectionID && e.localID == fileToUpload.localID,+ e.collectionID != toCollectionID &&+ (e.localID == fileToUpload.localID || isSandBoxFile),);if (fileExistsButDifferentCollection != null) {_logger.fine(- "fileExistsButDifferentCollection: \n toUpload ${fileToUpload.tag} "- "\n existing: ${fileExistsButDifferentCollection.tag}",+ "fileExistsButDifferentCollection: toUpload ${fileToUpload.tag} "+ "existing: ${fileExistsButDifferentCollection.tag} $isSandBoxFile",);final linkedFile = await CollectionsService.instance.linkLocalFileToExistingUploadedFileInAnotherCollection(