Skip to content

armgit / ente

Public Imported from GitHub
0

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

Envision the API

Manav Rathi8a728abffef1
diff --git a/web/apps/photos/src/services/watch.ts b/web/apps/photos/src/services/watch.ts
index c8f330386c..e001a1fa48 100644
--- a/web/apps/photos/src/services/watch.ts
+++ b/web/apps/photos/src/services/watch.ts
@@ -115,18 +115,12 @@ class FolderWatcher {
* collection do files belonging to nested directories go to.
*/
async addWatch(folderPath: string, mapping: CollectionMapping) {
- const rootFolderName = basename(folderPath)
- await ensureElectron().addWatchMapping(
- rootFolderName,
- folderPath,
- mapping,
- );
+ await ensureElectron().watch.add(folderPath, mapping);
this.syncWithDisk();
}
/**
- * Remove the folder watch corresponding to the given root
- * {@link folderPath}.
+ * Remove the folder watch for the given root {@link folderPath}.
*/
async removeWatchForFolderPath(folderPath: string) {
await ensureElectron().removeWatchMapping(folderPath);
diff --git a/web/packages/next/types/ipc.ts b/web/packages/next/types/ipc.ts
index c2adc517b9..23f7e24304 100644
--- a/web/packages/next/types/ipc.ts
+++ b/web/packages/next/types/ipc.ts
@@ -315,6 +315,24 @@ export interface Electron {
folderPath: string,
collectionMapping: CollectionMapping,
) => Promise<void>;
+
+ /**
+ * Remove the pre-existing watch for the given {@link folderPath}.
+ *
+ * Persist this removal, and also stop listening for file system events
+ * that happen within the {@link folderPath}.
+ */
+ remove: (folderPath: string) => Promise<void>;
+
+ /**
+ * Return the list of folder watches.
+ *
+ * The list of folder paths (and auxillary details) is persisted in the
+ * Node.js layer. When we invoke this method, the Node.js goes through
+ * the list, permanently removes any watches whose on-disk directory has
+ * is no longer present, and returns this pruned list of watches.
+ */
+ get: () => Promise<FolderWatch[]>;
};
registerWatcherFunctions: (
@@ -323,12 +341,6 @@ export interface Electron {
removeFolder: (folderPath: string) => Promise<void>,
) => void;
- addWatchMapping: (
- collectionName: string,
- folderPath: string,
- uploadStrategy: number,
- ) => Promise<void>;
-
removeWatchMapping: (folderPath: string) => Promise<void>;
/**
@@ -409,13 +421,6 @@ export interface AppUpdate {
* side.
*/
export interface FolderWatch {
- /**
- * Name of the root folder.
- *
- * This is just `basename(folderPath)`, but is retained as a precomputed
- * property for convenience instead of needing to recompute it every time.
- */
- rootFolderName: string;
/**
* Specify if nested files should all be mapped to the same single root
* collection, or if there should be a collection per directory that has