浏览代码

Fix: Handle live photo on/off change during upload

Neeraj Gupta 1 年之前
父节点
当前提交
e75958555a
共有 3 个文件被更改,包括 13 次插入2 次删除
  1. 1 1
      ios/Podfile.lock
  2. 7 0
      lib/core/errors.dart
  3. 5 1
      lib/utils/file_uploader.dart

+ 1 - 1
ios/Podfile.lock

@@ -326,7 +326,7 @@ EXTERNAL SOURCES:
 SPEC CHECKSUMS:
 SPEC CHECKSUMS:
   background_fetch: bc9b44b0bf8b434e282a2ac9be8662800a0296ed
   background_fetch: bc9b44b0bf8b434e282a2ac9be8662800a0296ed
   camera_avfoundation: 3125e8cd1a4387f6f31c6c63abb8a55892a9eeeb
   camera_avfoundation: 3125e8cd1a4387f6f31c6c63abb8a55892a9eeeb
-  connectivity_plus: 413a8857dd5d9f1c399a39130850d02fe0feaf7e
+  connectivity_plus: 53efb943fc2882c8512d84c45707bcabc4c36076
   device_info: d7d233b645a32c40dfdc212de5cf646ca482f175
   device_info: d7d233b645a32c40dfdc212de5cf646ca482f175
   Firebase: bd152f0f3d278c4060c5c71359db08ebcfd5a3e2
   Firebase: bd152f0f3d278c4060c5c71359db08ebcfd5a3e2
   firebase_core: ce64b0941c6d87c6ef5022ae9116a158236c8c94
   firebase_core: ce64b0941c6d87c6ef5022ae9116a158236c8c94

+ 7 - 0
lib/core/errors.dart

@@ -7,6 +7,13 @@ enum InvalidReason {
   livePhotoVideoMissing,
   livePhotoVideoMissing,
   thumbnailMissing,
   thumbnailMissing,
   unknown,
   unknown,
+
+}
+extension InvalidReasonExn on InvalidReason {
+  bool get isLivePhotoErr =>
+      this == InvalidReason.livePhotoToImageTypeChanged ||
+      this == InvalidReason.imageToLivePhotoTypeChanged ||
+      this == InvalidReason.livePhotoVideoMissing;
 }
 }
 
 
 class InvalidFileError extends ArgumentError {
 class InvalidFileError extends ArgumentError {

+ 5 - 1
lib/utils/file_uploader.dart

@@ -736,7 +736,11 @@ class FileUploader {
         file.deviceFolder != null &&
         file.deviceFolder != null &&
         file.title != null &&
         file.title != null &&
         !file.isSharedMediaToAppSandbox;
         !file.isSharedMediaToAppSandbox;
-    final bool deleteEntry = !file.isUploaded && !canIgnoreFile;
+    // If the file is not uploaded yet and either it can not be ignored or the
+    // err is related to live photo media, delete the local entry
+    final bool deleteEntry = !file.isUploaded &&
+        (!canIgnoreFile || e.reason.isLivePhotoErr);
+
     if (e.reason != InvalidReason.thumbnailMissing || !canIgnoreFile) {
     if (e.reason != InvalidReason.thumbnailMissing || !canIgnoreFile) {
       _logger.severe(
       _logger.severe(
         "Invalid file, localDelete: $deleteEntry, ignored: $canIgnoreFile",
         "Invalid file, localDelete: $deleteEntry, ignored: $canIgnoreFile",