diff --git a/desktop/src/main/ipc.ts b/desktop/src/main/ipc.ts index 825a2ed32..093724251 100644 --- a/desktop/src/main/ipc.ts +++ b/desktop/src/main/ipc.ts @@ -53,6 +53,7 @@ import { } from "./services/store"; import { getElectronFilesFromGoogleZip, + lsZip, pendingUploads, setPendingUploadCollection, setPendingUploadFiles, @@ -210,6 +211,8 @@ export const attachIPCHandlers = () => { setPendingUploadFiles(type, filePaths), ); + ipcMain.handle("lsZip", (_, zipPath: string) => lsZip(zipPath)); + // - ipcMain.handle("getElectronFilesFromGoogleZip", (_, filePath: string) => diff --git a/desktop/src/main/services/upload.ts b/desktop/src/main/services/upload.ts index 88c2d88d1..245edafe6 100644 --- a/desktop/src/main/services/upload.ts +++ b/desktop/src/main/services/upload.ts @@ -69,6 +69,10 @@ const storeKey = (type: PendingUploads["type"]): keyof UploadStatusStore => { } }; +export const lsZip = async (zipPath: string) => { + return [zipPath]; +}; + export const getElectronFilesFromGoogleZip = async (filePath: string) => { const zip = new StreamZip.async({ file: filePath, diff --git a/desktop/src/preload.ts b/desktop/src/preload.ts index 18fb55013..244cc9ffc 100644 --- a/desktop/src/preload.ts +++ b/desktop/src/preload.ts @@ -253,6 +253,9 @@ const setPendingUploadFiles = ( ): Promise => ipcRenderer.invoke("setPendingUploadFiles", type, filePaths); +const lsZip = (zipPath: string): Promise => + ipcRenderer.invoke("lsZip", zipPath); + // - TODO: AUDIT below this // - @@ -373,6 +376,7 @@ contextBridge.exposeInMainWorld("electron", { pendingUploads, setPendingUploadCollection, setPendingUploadFiles, + lsZip, // - diff --git a/web/apps/photos/src/utils/native-stream.ts b/web/apps/photos/src/utils/native-stream.ts index 85d54b790..ed7b16a79 100644 --- a/web/apps/photos/src/utils/native-stream.ts +++ b/web/apps/photos/src/utils/native-stream.ts @@ -2,6 +2,8 @@ * @file Streaming IPC communication with the Node.js layer of our desktop app. * * NOTE: These functions only work when we're running in our desktop app. + * + * See: [Note: IPC streams]. */ import type { Electron } from "@/next/types/ipc"; diff --git a/web/packages/next/types/ipc.ts b/web/packages/next/types/ipc.ts index 1622a820d..f00409b00 100644 --- a/web/packages/next/types/ipc.ts +++ b/web/packages/next/types/ipc.ts @@ -491,6 +491,19 @@ export interface Electron { filePaths: string[], ) => Promise; + /** + * Get the list of files that are present in the given zip file. + * + * @param zipPath The path of the zip file on the user's local file system. + * + * @returns A list of paths, one for each file in the given zip. Directories + * are traversed recursively, but the directory entries themselves will be + * excluded from the returned list. + * + * To read the contents of the files themselves, see [Note: IPC streams]. + */ + lsZip: (zipPath: string) => Promise; + /* * TODO: AUDIT below this - Some of the types we use below are not copyable * across process boundaries, and such functions will (expectedly) fail at