Manav Rathi 1 ano atrás
pai
commit
e65307517d

+ 3 - 0
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) =>

+ 4 - 0
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,

+ 4 - 0
desktop/src/preload.ts

@@ -253,6 +253,9 @@ const setPendingUploadFiles = (
 ): Promise<void> =>
     ipcRenderer.invoke("setPendingUploadFiles", type, filePaths);
 
+const lsZip = (zipPath: string): Promise<string[]> =>
+    ipcRenderer.invoke("lsZip", zipPath);
+
 // - TODO: AUDIT below this
 // -
 
@@ -373,6 +376,7 @@ contextBridge.exposeInMainWorld("electron", {
     pendingUploads,
     setPendingUploadCollection,
     setPendingUploadFiles,
+    lsZip,
 
     // -
 

+ 2 - 0
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";

+ 13 - 0
web/packages/next/types/ipc.ts

@@ -491,6 +491,19 @@ export interface Electron {
         filePaths: string[],
     ) => Promise<void>;
 
+    /**
+     * 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<string[]>;
+
     /*
      * TODO: AUDIT below this - Some of the types we use below are not copyable
      * across process boundaries, and such functions will (expectedly) fail at