Bläddra i källkod

chokidar seemed to have gotten stuck after a close

Not sure if something else was off, but after a close new watches in the same
session (after logging in) stopped reacting.
Manav Rathi 1 år sedan
förälder
incheckning
90b5054fcb
2 ändrade filer med 4 tillägg och 4 borttagningar
  1. 2 2
      desktop/src/main/services/watch.ts
  2. 2 2
      desktop/src/preload.ts

+ 2 - 2
desktop/src/main/services/watch.ts

@@ -151,6 +151,6 @@ export const watchFindFiles = async (dirPath: string) => {
     return paths;
 };
 
-export const watchReset = async (watcher: FSWatcher) => {
-    await watcher.close();
+export const watchReset = (watcher: FSWatcher) => {
+    watcher.unwatch(folderWatches().map((watch) => watch.folderPath));
 };

+ 2 - 2
desktop/src/preload.ts

@@ -208,11 +208,11 @@ const watchOnRemoveDir = (f: (path: string, watch: FolderWatch) => void) => {
 const watchFindFiles = (folderPath: string) =>
     ipcRenderer.invoke("watchFindFiles", folderPath);
 
-const watchReset = () => {
+const watchReset = async () => {
     ipcRenderer.removeAllListeners("watchAddFile");
     ipcRenderer.removeAllListeners("watchRemoveFile");
     ipcRenderer.removeAllListeners("watchRemoveDir");
-    return ipcRenderer.invoke("watchReset");
+    await ipcRenderer.invoke("watchReset");
 };
 
 // - Upload