Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Take 2

Manav Rathi3b6204f47dd5
diff --git a/desktop/src/main/ipc.ts b/desktop/src/main/ipc.ts
index 6e8bbe3f71..271577aa04 100644
--- a/desktop/src/main/ipc.ts
+++ b/desktop/src/main/ipc.ts
@@ -52,11 +52,12 @@ import {
saveEncryptionKey,
} from "./services/store";
import {
+ clearPendingUploads,
lsZip,
+ markUploadedFiles,
+ markUploadedZipEntries,
pendingUploads,
setPendingUploads,
- markUploaded,
- clearPendingUploads,
} from "./services/upload";
import {
watchAdd,
@@ -205,18 +206,20 @@ export const attachIPCHandlers = () => {
ipcMain.handle("setPendingUploads", (_, pendingUploads: PendingUploads) =>
setPendingUploads(pendingUploads),
-
- ipcMain.handle("markUploaded", (_, pathOrZipEntry: string | [zipPath: string, entryName: string]) =>
- markUploaded(pathOrZipEntry),
);
- ipcMain.handle("clearPendingUploads", () => clearPendingUploads());
-
- // -
+ ipcMain.handle(
+ "markUploadedFiles",
+ (_, paths: PendingUploads["filePaths"]) => markUploadedFiles(paths),
+ );
- ipcMain.handle("getElectronFilesFromGoogleZip", (_, filePath: string) =>
- getElectronFilesFromGoogleZip(filePath),
+ ipcMain.handle(
+ "markUploadedZipEntries",
+ (_, zipEntries: PendingUploads["zipEntries"]) =>
+ markUploadedZipEntries(zipEntries),
);
+
+ ipcMain.handle("clearPendingUploads", () => clearPendingUploads());
};
/**
diff --git a/desktop/src/main/services/upload.ts b/desktop/src/main/services/upload.ts
index 66c97e34c7..ebd1f481f1 100644
--- a/desktop/src/main/services/upload.ts
+++ b/desktop/src/main/services/upload.ts
@@ -60,9 +60,21 @@ export const pendingUploads = async (): Promise<PendingUploads | undefined> => {
export const setPendingUploads = async (pendingUploads: PendingUploads) =>
uploadStatusStore.set(pendingUploads);
-export const markUploaded = async (
- pathOrZipEntry: string | [zipPath: string, entryName: string],
-) => {};
+export const markUploadedFiles = async (paths: string[]) => {
+ const existing = uploadStatusStore.get("filePaths");
+ const updated = existing.filter((p) => !paths.includes(p));
+ uploadStatusStore.set("filePaths", updated);
+};
+
+export const markUploadedZipEntries = async (
+ entries: [zipPath: string, entryName: string][],
+) => {
+ const existing = uploadStatusStore.get("zipEntries");
+ const updated = existing.filter(
+ (z) => !entries.some((e) => z[0] == e[0] && z[1] == e[1]),
+ );
+ uploadStatusStore.set("zipEntries", updated);
+};
const validSavedPaths = (type: PendingUploads["type"]) => {
const key = storeKey(type);
diff --git a/desktop/src/preload.ts b/desktop/src/preload.ts
index c3737aceba..484a3bc0e2 100644
--- a/desktop/src/preload.ts
+++ b/desktop/src/preload.ts
@@ -250,9 +250,12 @@ const pendingUploads = (): Promise<PendingUploads | undefined> =>
const setPendingUploads = (pendingUploads: PendingUploads): Promise<void> =>
ipcRenderer.invoke("setPendingUploads", pendingUploads);
-const markUploaded = (
- pathOrZipEntry: string | [zipPath: string, entryName: string],
-): Promise<void> => ipcRenderer.invoke("markUploaded", pathOrZipEntry);
+const markUploadedFiles = (paths: PendingUploads["filePaths"]): Promise<void> =>
+ ipcRenderer.invoke("markUploadedFiles", paths);
+
+const markUploadedZipEntries = (
+ zipEntries: PendingUploads["zipEntries"],
+): Promise<void> => ipcRenderer.invoke("markUploadedZipEntries", zipEntries);
const clearPendingUploads = (): Promise<void> =>
ipcRenderer.invoke("clearPendingUploads");
@@ -369,6 +372,7 @@ contextBridge.exposeInMainWorld("electron", {
lsZip,
pendingUploads,
setPendingUploads,
- markUploaded,
+ markUploadedFiles,
+ markUploadedZipEntries,
clearPendingUploads,
});
diff --git a/web/packages/next/types/ipc.ts b/web/packages/next/types/ipc.ts
index e340e7a061..761cd72f1d 100644
--- a/web/packages/next/types/ipc.ts
+++ b/web/packages/next/types/ipc.ts
@@ -501,11 +501,16 @@ export interface Electron {
setPendingUploads: (pendingUploads: PendingUploads) => Promise<void>;
/**
- * Update the list of files (of {@link type}) associated with the pending
- * upload.
+ * Mark the given files (given by their {@link paths}) as having been
+ * uploaded.
+ */
+ markUploadedFiles: (paths: PendingUploads["filePaths"]) => Promise<void>;
+
+ /**
+ * Mark the given zip file entries as having been uploaded.
*/
- markUploaded: (
- pathOrZipEntry: string | [zipPath: string, entryName: string],
+ markUploadedZipEntries: (
+ entries: PendingUploads["zipEntries"],
) => Promise<void>;
/**