π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
fix(save.ts):fixing-retry-part-number
Aswin Asokfe411fe6e384
diff --git a/web/apps/photos/src/components/DownloadStatusNotifications.tsx b/web/apps/photos/src/components/DownloadStatusNotifications.tsxindex c7ccf86b93..e00714148b 100644--- a/web/apps/photos/src/components/DownloadStatusNotifications.tsx+++ b/web/apps/photos/src/components/DownloadStatusNotifications.tsx@@ -115,7 +115,9 @@ export const DownloadStatusNotifications: React.FC<? failedTitle: isSaveComplete(group)? t("download_complete")- : t("downloading_album", { name: group.title }),+ : group.downloadDirPath+ ? t("downloading_album", { name: group.title })+ : t("creating_zip", { name: group.title }),caption: isSaveComplete(group)? group.title: t("download_progress", {diff --git a/web/packages/base/locales/en-US/translation.json b/web/packages/base/locales/en-US/translation.jsonindex dbe0293d58..e6c761b151 100644--- a/web/packages/base/locales/en-US/translation.json+++ b/web/packages/base/locales/en-US/translation.json@@ -657,6 +657,7 @@"unpreviewable_file_message": "This file could not be previewed","download_complete": "Download complete","downloading_album": "Downloading {{name}}",+ "creating_zip": "Creating ZIP for {{name}}","download_failed": "Download failed","download_failed_network_offline": "Connection lost","download_failed_file_error": "Some files failed",diff --git a/web/packages/gallery/services/save.ts b/web/packages/gallery/services/save.tsindex 9848a47ce3..449b9fd6ce 100644--- a/web/packages/gallery/services/save.ts+++ b/web/packages/gallery/services/save.ts@@ -154,6 +154,10 @@ const downloadAndSave = async (const failedFiles: EnteFile[] = [];let isDownloading = false;let updateSaveGroup: UpdateSaveGroup = () => undefined;+ // Track the next ZIP batch index across retries so part numbers continue+ // sequentially (e.g., if initial download creates Parts 1-5 and fails,+ // retry creates Part 6+ instead of starting over at Part 1).+ let nextZipBatchIndex = 1;const downloadFilesDesktop = async (filesToDownload: EnteFile[],@@ -246,7 +250,7 @@ const downloadAndSave = async (}} else {// Multiple files or live photo: use ZIP- await saveAsZip(+ nextZipBatchIndex = await saveAsZip(filesToDownload,title,() =>@@ -263,6 +267,7 @@ const downloadAndSave = async (},canceller,updateSaveGroup,+ nextZipBatchIndex,);}@@ -303,14 +308,23 @@ class ZipBatcher {private zip = new JSZip();private currentBatchSize = 0;private currentFileCount = 0;- private batchIndex = 1;+ private batchIndex: number;private usedNames = new Set<string>();private baseName: string;private maxZipSize: number;- constructor(baseName: string, maxZipSize: number) {+ constructor(baseName: string, maxZipSize: number, startingBatchIndex = 1) {this.baseName = baseName;this.maxZipSize = maxZipSize;+ this.batchIndex = startingBatchIndex;+ }++ /**+ * Get the next batch index that would be used for the next ZIP file.+ * This is useful for tracking progress across retries.+ */+ getNextBatchIndex(): number {+ return this.batchIndex;}/**@@ -352,10 +366,7 @@ class ZipBatcher {this.currentFileCount === 1? "1 file": `${this.currentFileCount} files`;- const zipName =- this.batchIndex === 1- ? `${this.baseName} (${fileLabel}).zip`- : `${this.baseName} (${fileLabel})-${this.batchIndex}.zip`;+ const zipName = `${this.baseName} Part ${this.batchIndex} - ${fileLabel}.zip`;const url = URL.createObjectURL(zipBlob);saveAsFileAndRevokeObjectURL(url, zipName);@@ -439,6 +450,8 @@ const downloadFileForZip = async (* @param onSuccess Callback invoked after each file is successfully added.* @param onError Callback invoked when a file fails to download.* @param canceller An AbortController to check for cancellation.+ * @param startingBatchIndex The batch index to start from (for retries).+ * @returns The next batch index to use for subsequent ZIPs (useful for retries).*/const saveAsZip = async (files: EnteFile[],@@ -447,9 +460,10 @@ const saveAsZip = async (onError: (file: EnteFile, error: unknown) => void,canceller: AbortController,updateSaveGroup: UpdateSaveGroup,-): Promise<void> => {+ startingBatchIndex = 1,+): Promise<number> => {const { concurrency, maxZipSize } = getDownloadLimits();- const batcher = new ZipBatcher(baseName, maxZipSize);+ const batcher = new ZipBatcher(baseName, maxZipSize, startingBatchIndex);// Queue of files to processlet fileIndex = 0;@@ -589,6 +603,8 @@ const saveAsZip = async (if (!canceller.signal.aborted) {await batcher.flush();}++ return batcher.getNextBatchIndex();} finally {// Clean up event listenerswindow.removeEventListener("offline", handleOffline);