π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Tinker
Manav Rathic2c5267e9b0b
diff --git a/web/apps/photos/src/services/upload/uploadManager.ts b/web/apps/photos/src/services/upload/uploadManager.tsindex 69487ee0d9..4315c52458 100644--- a/web/apps/photos/src/services/upload/uploadManager.ts+++ b/web/apps/photos/src/services/upload/uploadManager.ts@@ -364,15 +364,14 @@ class UploadManager {uploaderName?: string,) {try {- if (this.uploadInProgress) {- throw Error("can't run multiple uploads at once");- }+ if (this.uploadInProgress)+ throw new Error("Cannot run multiple uploads at once");++ log.info(`Uploading ${filesWithCollectionToUploadIn.length} files`);this.uploadInProgress = true;await this.updateExistingFilesAndCollections(collections);this.uploaderName = uploaderName;- log.info(- `received ${filesWithCollectionToUploadIn.length} files to upload`,- );+this.uiService.setFilenames(new Map<number, string>(filesWithCollectionToUploadIn.map((mediaFile) => [@@ -381,10 +380,10 @@ class UploadManager {]),),);+const { metadataJSONFiles, mediaFiles } =segregateMetadataAndMediaFiles(filesWithCollectionToUploadIn);- log.info(`has ${metadataJSONFiles.length} metadata json files`);- log.info(`has ${mediaFiles.length} media files`);+if (metadataJSONFiles.length) {this.uiService.setUploadStage(UPLOAD_STAGES.READING_GOOGLE_METADATA_FILES,@@ -458,44 +457,21 @@ class UploadManager {};private async parseMetadataJSONFiles(metadataFiles: FileWithCollection2[]) {- try {- log.info(`parseMetadataJSONFiles function executed `);+ this.uiService.reset(metadataFiles.length);- this.uiService.reset(metadataFiles.length);+ for (const { file, collectionID } of metadataFiles) {+ this.abortIfCancelled();- for (const { file, collectionID } of metadataFiles) {- this.abortIfCancelled();- const name = getFileName(file);- try {- log.info(`parsing metadata json file ${name}`);-- const metadataJSON =- await tryParseTakeoutMetadataJSON(file);- if (metadataJSON) {- this.parsedMetadataJSONMap.set(- getMetadataJSONMapKeyForJSON(collectionID, name),- metadataJSON && { ...metadataJSON },- );- this.uiService.increaseFileUploaded();- }- log.info(`successfully parsed metadata json file ${name}`);- } catch (e) {- if (e.message === CustomError.UPLOAD_CANCELLED) {- throw e;- } else {- // and don't break for subsequent files just log and move on- log.error("parsing failed for a file", e);- log.info(- `failed to parse metadata json file ${name} error: ${e.message}`,- );- }- }- }- } catch (e) {- if (e.message !== CustomError.UPLOAD_CANCELLED) {- log.error("error seeding MetadataMap", e);+ const fileName = getFileName(file);+ log.info(`Parsing metadata JSON ${fileName}`);+ const metadataJSON = await tryParseTakeoutMetadataJSON(file);+ if (metadataJSON) {+ this.parsedMetadataJSONMap.set(+ getMetadataJSONMapKeyForJSON(collectionID, fileName),+ metadataJSON,+ );+ this.uiService.increaseFileUploaded();}- throw e;}}diff --git a/web/apps/photos/src/utils/upload/index.ts b/web/apps/photos/src/utils/upload/index.tsindex 0894f1cc1b..099287db9b 100644--- a/web/apps/photos/src/utils/upload/index.ts+++ b/web/apps/photos/src/utils/upload/index.ts@@ -6,8 +6,6 @@ import isElectron from "is-electron";import { exportMetadataDirectoryName } from "services/export";import { FileWithCollection, type FileWithCollection2 } from "types/upload";-const TYPE_JSON = "json";-export const hasFileHash = (file: Metadata) =>file.hash || (file.imageHash && file.videoHash);@@ -18,7 +16,7 @@ export function segregateMetadataAndMediaFiles(const mediaFiles: FileWithCollection[] = [];filesWithCollectionToUpload.forEach((fileWithCollection) => {const file = fileWithCollection.file;- if (file.name.toLowerCase().endsWith(TYPE_JSON)) {+ if (file.name.toLowerCase().endsWith("json")) {metadataJSONFiles.push(fileWithCollection);} else {mediaFiles.push(fileWithCollection);