Skip to content

armgit / ente

Public Imported from GitHub
0

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

Move

Manav Rathie0fae2e4992b
diff --git a/web/apps/photos/src/services/export/index.ts b/web/apps/photos/src/services/export/index.ts
index b310115450..1406ab53ac 100644
--- a/web/apps/photos/src/services/export/index.ts
+++ b/web/apps/photos/src/services/export/index.ts
@@ -25,16 +25,9 @@ import { PromiseQueue } from "@/utils/promise";
import { CustomError } from "@ente/shared/error";
import { LS_KEYS, getData, setData } from "@ente/shared/storage/localStorage";
import i18n from "i18next";
-import {
- CollectionExportNames,
- ExportProgress,
- ExportRecord,
- ExportSettings,
- ExportUIUpdaters,
- FileExportNames,
-} from "types/export";
+import { ExportProgress, ExportSettings, ExportUIUpdaters } from "types/export";
import { getAllLocalCollections } from "../collectionService";
-import { migrateExport } from "./migration";
+import { migrateExport, type ExportRecord } from "./migration";
/** Name of the JSON file in which we keep the state of the export. */
const exportRecordFileName = "export_status.json";
@@ -56,6 +49,10 @@ export enum ExportStage {
FINISHED = 7,
}
+export type CollectionExportNames = Record<number, string>;
+
+export type FileExportNames = Record<string, string>;
+
export const NULL_EXPORT_RECORD: ExportRecord = {
version: 3,
lastAttemptTimestamp: null,
diff --git a/web/apps/photos/src/services/export/migration.ts b/web/apps/photos/src/services/export/migration.ts
index a29ef68ce5..6c17ced792 100644
--- a/web/apps/photos/src/services/export/migration.ts
+++ b/web/apps/photos/src/services/export/migration.ts
@@ -3,7 +3,7 @@ import { nameAndExtension } from "@/base/file-name";
import log from "@/base/log";
import { downloadManager } from "@/gallery/services/download";
import type { Collection } from "@/media/collection";
-import { type EnteFile, mergeMetadata } from "@/media/file";
+import { mergeMetadata, type EnteFile } from "@/media/file";
import { FileType } from "@/media/file-type";
import { decodeLivePhoto } from "@/media/live-photo";
import { exportMetadataDirectoryName } from "@/new/photos/services/export";
@@ -17,25 +17,57 @@ import { wait } from "@/utils/promise";
import { LS_KEYS, getData } from "@ente/shared/storage/localStorage";
import type { User } from "@ente/shared/user/types";
import { getLocalCollections } from "services/collectionService";
-import {
- CollectionExportNames,
- ExportProgress,
- ExportRecord,
- ExportRecordV0,
- ExportRecordV1,
- ExportRecordV2,
- ExportedCollectionPaths,
- FileExportNames,
-} from "types/export";
+import { ExportProgress } from "types/export";
import { getIDBasedSortedFiles, getPersonalFiles } from "utils/file";
import {
getCollectionIDFromFileUID,
getExportRecordFileUID,
getLivePhotoExportName,
getMetadataFolderExportPath,
+ type CollectionExportNames,
+ type ExportStage,
+ type FileExportNames,
} from ".";
import exportService from "./index";
+type ExportedCollectionPaths = Record<number, string>;
+
+interface ExportRecordV0 {
+ stage: ExportStage;
+ lastAttemptTimestamp: number;
+ progress: ExportProgress;
+ queuedFiles: string[];
+ exportedFiles: string[];
+ failedFiles: string[];
+}
+
+interface ExportRecordV1 {
+ version: number;
+ stage: ExportStage;
+ lastAttemptTimestamp: number;
+ progress: ExportProgress;
+ queuedFiles: string[];
+ exportedFiles: string[];
+ failedFiles: string[];
+ exportedCollectionPaths: ExportedCollectionPaths;
+}
+
+interface ExportRecordV2 {
+ version: number;
+ stage: ExportStage;
+ lastAttemptTimestamp: number;
+ exportedFiles: string[];
+ exportedCollectionPaths: ExportedCollectionPaths;
+}
+
+export interface ExportRecord {
+ version: number;
+ stage: ExportStage;
+ lastAttemptTimestamp: number;
+ collectionExportNames: CollectionExportNames;
+ fileExportNames: FileExportNames;
+}
+
export async function migrateExport(
exportDir: string,
exportRecord: ExportRecordV1 | ExportRecordV2 | ExportRecord,
diff --git a/web/apps/photos/src/types/export/index.ts b/web/apps/photos/src/types/export/index.ts
index 5c4c624eed..403769316b 100644
--- a/web/apps/photos/src/types/export/index.ts
+++ b/web/apps/photos/src/types/export/index.ts
@@ -6,47 +6,6 @@ export interface ExportProgress {
failed: number;
total: number;
}
-export type ExportedCollectionPaths = Record<number, string>;
-
-export type CollectionExportNames = Record<number, string>;
-
-export type FileExportNames = Record<string, string>;
-
-export interface ExportRecordV0 {
- stage: ExportStage;
- lastAttemptTimestamp: number;
- progress: ExportProgress;
- queuedFiles: string[];
- exportedFiles: string[];
- failedFiles: string[];
-}
-
-export interface ExportRecordV1 {
- version: number;
- stage: ExportStage;
- lastAttemptTimestamp: number;
- progress: ExportProgress;
- queuedFiles: string[];
- exportedFiles: string[];
- failedFiles: string[];
- exportedCollectionPaths: ExportedCollectionPaths;
-}
-
-export interface ExportRecordV2 {
- version: number;
- stage: ExportStage;
- lastAttemptTimestamp: number;
- exportedFiles: string[];
- exportedCollectionPaths: ExportedCollectionPaths;
-}
-
-export interface ExportRecord {
- version: number;
- stage: ExportStage;
- lastAttemptTimestamp: number;
- collectionExportNames: CollectionExportNames;
- fileExportNames: FileExportNames;
-}
export interface ExportSettings {
folder: string;