diff --git a/web/apps/photos/src/services/watch.ts b/web/apps/photos/src/services/watch.ts index c8f330386..e001a1fa4 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 c2adc517b..23f7e2430 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; + + /** + * 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; + + /** + * 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; }; registerWatcherFunctions: ( @@ -323,12 +341,6 @@ export interface Electron { removeFolder: (folderPath: string) => Promise, ) => void; - addWatchMapping: ( - collectionName: string, - folderPath: string, - uploadStrategy: number, - ) => Promise; - removeWatchMapping: (folderPath: string) => Promise; /** @@ -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