π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Remove duplicate state and reset store on successful completion
Manav Rathi42b214a4ba45
diff --git a/web/apps/photos/src/services/upload/uploadManager.ts b/web/apps/photos/src/services/upload/uploadManager.tsindex 99fe6ced39..3d53adbeaf 100644--- a/web/apps/photos/src/services/upload/uploadManager.ts+++ b/web/apps/photos/src/services/upload/uploadManager.ts@@ -321,7 +321,6 @@ class UploadManager {>(maxConcurrentUploads);private parsedMetadataJSONMap: Map<string, ParsedMetadataJSON>;private itemsToBeUploaded: ClusteredUploadItem[];- private remainingItems: ClusteredUploadItem[] = [];private failedItems: ClusteredUploadItem[];private existingFiles: EnteFile[];private setFiles: SetFiles;@@ -360,7 +359,6 @@ class UploadManager {private resetState() {this.itemsToBeUploaded = [];- this.remainingItems = [];this.failedItems = [];this.parsedMetadataJSONMap = new Map<string, ParsedMetadataJSON>();@@ -440,17 +438,13 @@ class UploadManager {await this.uploadMediaItems(clusteredMediaItems);}} catch (e) {- if (e.message === CustomError.UPLOAD_CANCELLED) {- if (isElectron()) {- this.remainingItems = [];- await cancelRemainingUploads();- }- } else {- log.error("Uploading failed", e);+ if (e.message != CustomError.UPLOAD_CANCELLED) {+ log.error("Upload failed", e);throw e;}} finally {this.uiService.setUploadStage(UPLOAD_STAGES.FINISH);+ void globalThis.electron?.clearPendingUploads();for (let i = 0; i < maxConcurrentUploads; i++) {this.cryptoWorkers[i]?.terminate();}@@ -503,15 +497,8 @@ class UploadManager {private async uploadMediaItems(mediaItems: ClusteredUploadItem[]) {this.itemsToBeUploaded = [...this.itemsToBeUploaded, ...mediaItems];-- if (isElectron()) {- this.remainingItems = [...this.remainingItems, ...mediaItems];- }-this.uiService.reset(mediaItems.length);-await UploadService.setFileCount(mediaItems.length);-this.uiService.setUploadStage(UPLOAD_STAGES.UPLOADING);const uploadProcesses = [];@@ -584,8 +571,10 @@ class UploadManager {`Uploaded ${uploadableItem.fileName} with result ${uploadResult}`,);try {+ const electron = globalThis.electron;+ if (electron) await markUploaded(electron, uploadableItem);+let decryptedFile: EnteFile;- await this.removeFromPendingUploads(uploadableItem);switch (uploadResult) {case UPLOAD_RESULT.FAILED:case UPLOAD_RESULT.BLOCKED:@@ -688,18 +677,6 @@ class UploadManager {this.setFiles((files) => sortFiles([...files, decryptedFile]));}- private async removeFromPendingUploads(- clusteredUploadItem: ClusteredUploadItem,- ) {- const electron = globalThis.electron;- if (electron) {- this.remainingItems = this.remainingItems.filter(- (f) => f.localID != clusteredUploadItem.localID,- );- await markUploaded(electron, clusteredUploadItem);- }- }-public shouldAllowNewUpload = () => {return !this.uploadInProgress || watcher.isUploadRunning();};@@ -847,8 +824,6 @@ const markUploaded = async (electron: Electron, item: ClusteredUploadItem) => {}};-const cancelRemainingUploads = () => ensureElectron().clearPendingUploads();-/*** Go through the given files, combining any sibling image + video assets into a* single live photo when appropriate.