This commit is contained in:
Manav Rathi 2024-04-28 17:08:22 +05:30
parent 0e9507be34
commit e65307517d
No known key found for this signature in database
5 changed files with 26 additions and 0 deletions

View file

@ -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) =>

View file

@ -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,

View file

@ -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,
// -

View file

@ -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";

View file

@ -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