Skip to content

armgit / ente

Public Imported from GitHub
0

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

Remove potentially dangerous wip forks

Manav Rathi239688b7d82e
diff --git a/web/apps/photos/src/components/Upload/Uploader.tsx b/web/apps/photos/src/components/Upload/Uploader.tsx
index 7b4bc4fa34..c340ee1dc3 100644
--- a/web/apps/photos/src/components/Upload/Uploader.tsx
+++ b/web/apps/photos/src/components/Upload/Uploader.tsx
@@ -489,7 +489,7 @@ export default function Uploader(props: Props) {
});
throw e;
}
- await waitInQueueAndUploadFiles2(
+ await waitInQueueAndUploadFiles(
filesWithCollectionToUpload,
collections,
);
@@ -517,24 +517,6 @@ export default function Uploader(props: Props) {
await currentUploadPromise.current;
};
- const waitInQueueAndUploadFiles2 = async (
- filesWithCollectionToUploadIn: FileWithCollection2[],
- collections: Collection[],
- uploaderName?: string,
- ) => {
- const currentPromise = currentUploadPromise.current;
- currentUploadPromise.current = waitAndRun(
- currentPromise,
- async () =>
- await uploadFiles2(
- filesWithCollectionToUploadIn,
- collections,
- uploaderName,
- ),
- );
- await currentUploadPromise.current;
- };
-
const preUploadAction = async () => {
uploadManager.prepareForNewUpload();
setUploadProgressView(true);
@@ -604,63 +586,6 @@ export default function Uploader(props: Props) {
}
};
- const uploadFiles2 = async (
- filesWithCollectionToUploadIn: FileWithCollection2[],
- collections: Collection[],
- uploaderName?: string,
- ) => {
- try {
- log.info("uploadFiles called");
- preUploadAction();
- if (
- electron &&
- !isPendingDesktopUpload.current &&
- !watcher.isUploadRunning()
- ) {
- await setToUploadCollection(collections);
- if (zipPaths.current) {
- await electron.setPendingUploadFiles(
- "zips",
- zipPaths.current,
- );
- zipPaths.current = null;
- }
- await electron.setPendingUploadFiles(
- "files",
- filesWithCollectionToUploadIn.map(
- ({ file }) => (file as ElectronFile).path,
- ),
- );
- }
- const shouldCloseUploadProgress =
- await uploadManager.queueFilesForUpload2(
- filesWithCollectionToUploadIn,
- collections,
- uploaderName,
- );
- if (shouldCloseUploadProgress) {
- closeUploadProgress();
- }
- if (isElectron()) {
- if (watcher.isUploadRunning()) {
- await watcher.allFileUploadsDone(
- filesWithCollectionToUploadIn,
- collections,
- );
- } else if (watcher.isSyncPaused()) {
- // resume the service after user upload is done
- watcher.resumePausedSync();
- }
- }
- } catch (e) {
- log.error("failed to upload files", e);
- showUserFacingError(e.message);
- closeUploadProgress();
- } finally {
- postUploadAction();
- }
- };
-
const retryFailed = async () => {
try {
log.info("user retrying failed upload");
diff --git a/web/apps/photos/src/services/upload/uploadManager.ts b/web/apps/photos/src/services/upload/uploadManager.ts
index 1a65b1be9f..4a18c48c1e 100644
--- a/web/apps/photos/src/services/upload/uploadManager.ts
+++ b/web/apps/photos/src/services/upload/uploadManager.ts
@@ -31,7 +31,6 @@ import {
FileWithCollection,
PublicUploadProps,
type FileWithCollection2,
- type LivePhotoAssets,
type LivePhotoAssets2,
} from "types/upload";
import {
@@ -45,7 +44,6 @@ import { decryptFile, getUserOwnedFiles, sortFiles } from "utils/file";
import {
areFileWithCollectionsSame,
segregateMetadataAndMediaFiles,
- segregateMetadataAndMediaFiles2,
} from "utils/upload";
import { getLocalFiles } from "../fileService";
import {
@@ -423,93 +421,6 @@ class UploadManager {
}
}
- public async queueFilesForUpload2(
- filesWithCollectionToUploadIn: FileWithCollection2[],
- collections: Collection[],
- uploaderName?: string,
- ) {
- try {
- if (this.uploadInProgress) {
- throw Error("can't run multiple uploads at once");
- }
- 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) => [
- mediaFile.localID,
- assetName(mediaFile),
- ]),
- ),
- );
- const { metadataJSONFiles, mediaFiles } =
- segregateMetadataAndMediaFiles2(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,
- );
- await this.parseMetadataJSONFiles(metadataJSONFiles);
- }
- if (mediaFiles.length) {
- log.info(`clusterLivePhotoFiles started`);
- const analysedMediaFiles =
- await clusterLivePhotoFiles(mediaFiles);
- log.info(`clusterLivePhotoFiles ended`);
- log.info(
- `got live photos: ${
- mediaFiles.length !== analysedMediaFiles.length
- }`,
- );
- this.uiService.setFilenames(
- new Map<number, string>(
- analysedMediaFiles.map((mediaFile) => [
- mediaFile.localID,
- assetName(mediaFile),
- ]),
- ),
- );
-
- this.uiService.setHasLivePhoto(
- mediaFiles.length !== analysedMediaFiles.length,
- );
-
- await this.uploadMediaFiles(analysedMediaFiles);
- }
- } catch (e) {
- if (e.message === CustomError.UPLOAD_CANCELLED) {
- if (isElectron()) {
- this.remainingFiles = [];
- await cancelRemainingUploads();
- }
- } else {
- log.error("uploading failed with error", e);
- throw e;
- }
- } finally {
- this.uiService.setUploadStage(UPLOAD_STAGES.FINISH);
- for (let i = 0; i < MAX_CONCURRENT_UPLOADS; i++) {
- this.cryptoWorkers[i]?.terminate();
- }
- this.uploadInProgress = false;
- }
- try {
- if (!this.uiService.hasFilesInResultList()) {
- return true;
- } else {
- return false;
- }
- } catch (e) {
- log.error(" failed to return shouldCloseProgressBar", e);
- return false;
- }
- }
-
private async parseMetadataJSONFiles(metadataFiles: FileWithCollection2[]) {
try {
log.info(`parseMetadataJSONFiles function executed `);
@@ -816,12 +727,12 @@ type ClusterableFile = {
collectionID: number;
// fileOrPath: File | ElectronFile | string;
file: File | ElectronFile | string;
-}
+};
type ClusteredFile = ClusterableFile & {
isLivePhoto: boolean;
livePhotoAssets?: LivePhotoAssets2;
-}
+};
/**
* Go through the given files, combining any sibling image + video assets into a
diff --git a/web/apps/photos/src/utils/upload/index.ts b/web/apps/photos/src/utils/upload/index.ts
index 6de421ca9b..091026e7be 100644
--- a/web/apps/photos/src/utils/upload/index.ts
+++ b/web/apps/photos/src/utils/upload/index.ts
@@ -30,23 +30,6 @@ export function segregateMetadataAndMediaFiles(
return { mediaFiles, metadataJSONFiles };
}
-export function segregateMetadataAndMediaFiles2(
- filesWithCollectionToUpload: FileWithCollection2[],
-) {
- const metadataJSONFiles: FileWithCollection2[] = [];
- const mediaFiles: FileWithCollection2[] = [];
- filesWithCollectionToUpload.forEach((fileWithCollection) => {
- const file = fileWithCollection.file;
- const s = typeof file == "string" ? file : file.name;
- if (s.toLowerCase().endsWith(TYPE_JSON)) {
- metadataJSONFiles.push(fileWithCollection);
- } else {
- mediaFiles.push(fileWithCollection);
- }
- });
- return { mediaFiles, metadataJSONFiles };
-}
-
export function areFileWithCollectionsSame(
firstFile: FileWithCollection2,
secondFile: FileWithCollection2,