Skip to content

armgit / ente

Public Imported from GitHub
0

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

Sep

Manav Rathi29bab5705b92
diff --git a/web/packages/gallery/services/upload/upload-service.ts b/web/packages/gallery/services/upload/upload-service.ts
index 0a42c9104a..1422972674 100644
--- a/web/packages/gallery/services/upload/upload-service.ts
+++ b/web/packages/gallery/services/upload/upload-service.ts
@@ -46,7 +46,11 @@ import { FileType, type FileTypeInfo } from "ente-media/file-type";
import { encodeLivePhoto } from "ente-media/live-photo";
import { addToCollection } from "ente-new/photos/services/collection";
import { settingsSnapshot } from "ente-new/photos/services/settings";
-import { CustomError, handleUploadError } from "ente-shared/error";
+import {
+ CustomError,
+ CustomErrorMessage,
+ handleUploadError,
+} from "ente-shared/error";
import { mergeUint8Arrays } from "ente-utils/array";
import { ensureInteger, ensureNumber } from "ente-utils/ensure";
import type { UploadableUploadItem, UploadItem } from ".";
@@ -726,7 +730,7 @@ export const upload = async (
const error = handleUploadError(e);
switch (error.message) {
- case CustomError.ETAG_MISSING:
+ case CustomErrorMessage.eTagMissing:
return { uploadResult: "blocked" };
case CustomError.FILE_TOO_LARGE:
return { uploadResult: "largerThanAvailableStorage" };
@@ -1662,7 +1666,7 @@ const uploadStreamUsingMultipart = async (
partData,
abortableRetryEnsuringHTTPOk,
);
- if (!eTag) throw new Error(CustomError.ETAG_MISSING);
+ if (!eTag) throw new Error(CustomErrorMessage.eTagMissing);
updateUploadProgress(fileLocalID, percentPerPart, partNumber);
completedParts.push({ partNumber, eTag });
diff --git a/web/packages/shared/error/index.ts b/web/packages/shared/error/index.ts
index 51c55c5d2f..348cc94676 100644
--- a/web/packages/shared/error/index.ts
+++ b/web/packages/shared/error/index.ts
@@ -21,6 +21,14 @@ export function isApiErrorResponse(object: any): object is ApiErrorResponse {
return object && "code" in object && "message" in object;
}
+/**
+ * Constant string values used mark custom errors that we need to subsequently
+ * catch and identify to deal with in a particular manner.
+ */
+export const CustomErrorMessage = {
+ eTagMissing: "ETag header not present in response",
+};
+
export const CustomError = {
ETAG_MISSING: "no header/etag present in response body",
FILE_TOO_LARGE: "file too large",
@@ -28,7 +36,6 @@ export const CustomError = {
STORAGE_QUOTA_EXCEEDED: "storage quota exceeded",
SESSION_EXPIRED: "session expired",
TOKEN_EXPIRED: "token expired",
- TOKEN_MISSING: "token missing",
TOO_MANY_REQUESTS: "too many requests",
BAD_REQUEST: "bad request",
SUBSCRIPTION_NEEDED: "subscription not present",