π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Pass
Manav Rathie4471af4cb9f
diff --git a/web/packages/base/http.ts b/web/packages/base/http.tsindex 394712d97a..38bb447608 100644--- a/web/packages/base/http.ts+++ b/web/packages/base/http.ts@@ -202,6 +202,13 @@ export const retryAsyncOperation = async <T>(}};+/**+ * A function that wraps the request(s) in retries if needed.+ *+ * See {@link retryEnsuringHTTPOk} for the canonical example. This typedef is to+ * allow us to talk about and pass functions that behave similar to+ * {@link retryEnsuringHTTPOk}, but perhaps with other additional checks.+ */export type HTTPRequestRetrier = (request: () => Promise<Response>,) => Promise<Response>;diff --git a/web/packages/gallery/services/upload/remote.ts b/web/packages/gallery/services/upload/remote.tsindex 768494a691..6e8476f54c 100644--- a/web/packages/gallery/services/upload/remote.ts+++ b/web/packages/gallery/services/upload/remote.ts@@ -8,7 +8,7 @@ import {ensureOk,publicRequestHeaders,retryAsyncOperation,- retryEnsuringHTTPOk,+ type HTTPRequestRetrier,type PublicAlbumsCredentials,} from "ente-base/http";import log from "ente-base/log";@@ -254,7 +254,7 @@ export class PhotosUploadHTTPClient {** @param partData The part bytes to upload.*- * @param onProgress A function to call to indicate upload progress.+ * @param retrier A function to wrap the request in retries if needed.** @returns the value of the "ETag" header in the remote response, or* `undefined` if the ETag was not present in the response (this is not expected@@ -265,9 +265,9 @@ export class PhotosUploadHTTPClient {export const putFilePart = async (partUploadURL: string,partData: Uint8Array,- onProgress: (bytesUploaded: number) => void,+ retrier: HTTPRequestRetrier,) => {- const res = await retryEnsuringHTTPOk(() =>+ const res = await retrier(() =>fetch(partUploadURL, {method: "PUT",headers: publicRequestHeaders(),diff --git a/web/packages/gallery/services/upload/upload-service.ts b/web/packages/gallery/services/upload/upload-service.tsindex a528626750..7864a15d1d 100644--- a/web/packages/gallery/services/upload/upload-service.ts+++ b/web/packages/gallery/services/upload/upload-service.ts@@ -1628,9 +1628,11 @@ async function uploadStreamUsingMultipart();} else {if (process.env.NEXT_PUBLIC_ENTE_WIP_MP) {- eTag = await putFilePart(partUploadURL, partData, (...args) => {- console.log("test progress", args);- });+ eTag = await putFilePart(+ partUploadURL,+ partData,+ abortableRetryEnsuringHTTPOk,+ );if (!eTag) throw new Error(CustomError.ETAG_MISSING);} else {eTag = await photosHTTPClient.putFilePart(