diff --git a/desktop/src/main/services/upload.ts b/desktop/src/main/services/upload.ts index a1103a748..c3efbb9f4 100644 --- a/desktop/src/main/services/upload.ts +++ b/desktop/src/main/services/upload.ts @@ -35,6 +35,10 @@ export const pathOrZipItemSize = async ( const [zipPath, entryName] = pathOrZipItem; const zip = new StreamZip.async({ file: zipPath }); const entry = await zip.entry(entryName); + if (!entry) + throw new Error( + `An entry with name ${entryName} does not exist in the zip file at ${zipPath}`, + ); const size = entry.size; zip.close(); return size; @@ -60,7 +64,7 @@ export const pendingUploads = async (): Promise => { // file, but the dedup logic will kick in at that point so no harm will come // off it. if (allZipItems === undefined) { - const allZipPaths = uploadStatusStore.get("filePaths"); + const allZipPaths = uploadStatusStore.get("filePaths") ?? []; const zipPaths = allZipPaths.filter((f) => existsSync(f)); zipItems = []; for (const zip of zipPaths) @@ -83,7 +87,7 @@ export const setPendingUploads = async (pendingUploads: PendingUploads) => export const markUploadedFiles = async (paths: string[]) => { const existing = uploadStatusStore.get("filePaths"); - const updated = existing.filter((p) => !paths.includes(p)); + const updated = existing?.filter((p) => !paths.includes(p)); uploadStatusStore.set("filePaths", updated); }; @@ -91,7 +95,7 @@ export const markUploadedZipItems = async ( items: [zipPath: string, entryName: string][], ) => { const existing = uploadStatusStore.get("zipItems"); - const updated = existing.filter( + const updated = existing?.filter( (z) => !items.some((e) => z[0] == e[0] && z[1] == e[1]), ); uploadStatusStore.set("zipItems", updated); diff --git a/desktop/src/types/ipc.ts b/desktop/src/types/ipc.ts index c02ed1726..c8c7ef6b4 100644 --- a/desktop/src/types/ipc.ts +++ b/desktop/src/types/ipc.ts @@ -28,7 +28,7 @@ export interface FolderWatchSyncedFile { export type ZipItem = [zipPath: string, entryName: string]; export interface PendingUploads { - collectionName: string; + collectionName?: string; filePaths: string[]; zipItems: ZipItem[]; } diff --git a/web/apps/photos/src/components/Upload/Uploader.tsx b/web/apps/photos/src/components/Upload/Uploader.tsx index 90b5f94b4..0d310d7f9 100644 --- a/web/apps/photos/src/components/Upload/Uploader.tsx +++ b/web/apps/photos/src/components/Upload/Uploader.tsx @@ -930,9 +930,5 @@ export const setPendingUploads = async ( } } - await electron.setPendingUploads({ - collectionName, - filePaths, - zipItems: zipItems, - }); + await electron.setPendingUploads({ collectionName, filePaths, zipItems }); }; diff --git a/web/packages/next/types/ipc.ts b/web/packages/next/types/ipc.ts index d97a7e564..895dfcf70 100644 --- a/web/packages/next/types/ipc.ts +++ b/web/packages/next/types/ipc.ts @@ -650,8 +650,10 @@ export interface PendingUploads { * This is name of the collection (when uploading to a singular collection) * or the root collection (when uploading to separate * albums) to which we * these uploads are meant to go to. See {@link CollectionMapping}. + * + * It will not be set if we're just uploading standalone files. */ - collectionName: string; + collectionName?: string; /** * Paths of regular files that need to be uploaded. */