Skip to content

armgit / ente

Public Imported from GitHub
0

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

Clean up multiPart errors

Neeraj Gupta5b83db579629
diff --git a/mobile/apps/photos/lib/core/errors.dart b/mobile/apps/photos/lib/core/errors.dart
index b22be2a194..ef75811280 100644
--- a/mobile/apps/photos/lib/core/errors.dart
+++ b/mobile/apps/photos/lib/core/errors.dart
@@ -1,3 +1,5 @@
+import "package:flutter/material.dart";
+
enum InvalidReason {
assetDeleted,
assetDeletedEvent,
@@ -84,10 +86,18 @@ class PassKeySessionNotVerifiedError extends Error {}
class PassKeySessionExpiredError extends Error {}
-class MultiPartUploadError implements Exception {
+class MultiPartMissingFileError implements Exception {
+ final String message;
+ MultiPartMissingFileError(this.message);
+
+ @override
+ String toString() => "MultiPartMissingFileError: $message";
+}
+
+class MultiPartError implements Exception {
final String message;
- MultiPartUploadError(this.message);
+ MultiPartError(this.message);
@override
- String toString() => "MultiPartUploadError: $message";
+ String toString() => "MultiPartError: $message";
}
diff --git a/mobile/apps/photos/lib/db/upload_locks_db.dart b/mobile/apps/photos/lib/db/upload_locks_db.dart
index 53a2ac14cd..498eb56904 100644
--- a/mobile/apps/photos/lib/db/upload_locks_db.dart
+++ b/mobile/apps/photos/lib/db/upload_locks_db.dart
@@ -347,16 +347,16 @@ class UploadLocksDB {
String encryptedFileName,
) {
if (rows.isEmpty) {
- throw MultiPartUploadError("No cached links found for $localId");
+ throw MultiPartError("No cached links found for $localId");
}
if (rows.length > 1) {
- throw MultiPartUploadError(
+ throw MultiPartError(
"Multiple entries found for localID: $localId",
);
}
if (encryptedFileName !=
rows.first[_trackUploadTable.columnEncryptedFileName]) {
- throw MultiPartUploadError(
+ throw MultiPartError(
"Encrypted file name mismatch for localID: $localId",
);
}
@@ -559,7 +559,7 @@ class UploadLocksDB {
where: '${_trackUploadTable.columnLocalID} = ?',
whereArgs: [localId],
);
- throw MultiPartUploadError(
+ throw MultiPartError(
"Multiple entries found for localID: $localId",
);
}
diff --git a/mobile/apps/photos/lib/utils/file_uploader.dart b/mobile/apps/photos/lib/utils/file_uploader.dart
index 698328a82f..ba44e6f27e 100644
--- a/mobile/apps/photos/lib/utils/file_uploader.dart
+++ b/mobile/apps/photos/lib/utils/file_uploader.dart
@@ -619,7 +619,7 @@ class FileUploader {
// that we'll have to re-upload as the nonce is lost
if (hasExistingMultiPart) {
if (!encryptedFileExists) {
- throw MultiPartUploadError(
+ throw MultiPartMissingFileError(
'multiPartResume: encryptedFile missing',
);
}
@@ -627,7 +627,7 @@ class FileUploader {
multiPartFileEncResult != null &&
!listEquals(key, multiPartFileEncResult.key);
if (updateWithDiffKey) {
- throw MultiPartUploadError(
+ throw MultiPartError(
'multiPart update resumed with differentKey',
);
}
@@ -901,7 +901,7 @@ class FileUploader {
}
bool isPutOrMultiPartError(Object e) {
- if (e is MultiPartUploadError) {
+ if (e is MultiPartMissingFileError || e is MultiPartError) {
return true;
}
if (e is DioException) {