diff --git a/web/apps/photos/src/services/export/index.ts b/web/apps/photos/src/services/export/index.ts index 5e53b99a18..7d9f09555c 100644 --- a/web/apps/photos/src/services/export/index.ts +++ b/web/apps/photos/src/services/export/index.ts @@ -22,7 +22,6 @@ import { writeStream } from "@/new/photos/utils/native-stream"; import { wait } from "@/utils/promise"; import { CustomError } from "@ente/shared/error"; import { LS_KEYS, getData, setData } from "@ente/shared/storage/localStorage"; -import type { User } from "@ente/shared/user/types"; import QueueProcessor, { CancellationStatus, RequestCanceller, @@ -40,7 +39,6 @@ import { constructCollectionNameMap, getCollectionUserFacingName, } from "utils/collection"; -import { getPersonalFiles } from "utils/file"; import { getAllLocalCollections } from "../collectionService"; import { migrateExport } from "./migration"; @@ -212,23 +210,10 @@ class ExportService { exportRecord: ExportRecord, ): Promise => { try { - const user: User = getData(LS_KEYS.USER); const files = await getAllLocalFiles(); - const collections = await getAllLocalCollections(); - const collectionIdToOwnerIDMap = new Map( - collections.map((collection) => [ - collection.id, - collection.owner.id, - ]), - ); - const userPersonalFiles = getPersonalFiles( - files, - user, - collectionIdToOwnerIDMap, - ); const unExportedFiles = getUnExportedFiles( - userPersonalFiles, + files, exportRecord, undefined, ); @@ -338,46 +323,29 @@ class ExportService { { resync }: ExportOpts, ) { try { - const user: User = getData(LS_KEYS.USER); const files = mergeMetadata(await getAllLocalFiles()); const collections = await getAllLocalCollections(); - const collectionIdToOwnerIDMap = new Map( - collections.map((collection) => [ - collection.id, - collection.owner.id, - ]), - ); - const personalFiles = getPersonalFiles( - files, - user, - collectionIdToOwnerIDMap, - ); - - const personalCollections = collections.filter( - (collection) => collection.owner.id === user?.id, - ); const exportRecord = await this.getExportRecord(exportFolder); const collectionIDExportNameMap = convertCollectionIDExportNameObjectToMap( exportRecord.collectionExportNames, ); - const collectionIDNameMap = - constructCollectionNameMap(personalCollections); + const collectionIDNameMap = constructCollectionNameMap(collections); const renamedCollections = getRenamedExportedCollections( - personalCollections, + collections, exportRecord, ); const removedFileUIDs = getDeletedExportedFiles( - personalFiles, + files, exportRecord, ); const diskFileRecordIDs = resync ? await readOnDiskFileExportRecordIDs( - personalFiles, + files, collectionIDExportNameMap, exportFolder, exportRecord, @@ -386,18 +354,18 @@ class ExportService { : undefined; const filesToExport = getUnExportedFiles( - personalFiles, + files, exportRecord, diskFileRecordIDs, ); const deletedExportedCollections = getDeletedExportedCollections( - personalCollections, + collections, exportRecord, ); log.info( - `personal files:${personalFiles.length} unexported files: ${filesToExport.length}, deleted exported files: ${removedFileUIDs.length}, renamed collections: ${renamedCollections.length}, deleted collections: ${deletedExportedCollections.length}`, + `files:${files.length} unexported files: ${filesToExport.length}, deleted exported files: ${removedFileUIDs.length}, renamed collections: ${renamedCollections.length}, deleted collections: ${deletedExportedCollections.length}`, ); let success = 0; let failed = 0;