Browse Source

fix(watcher): avoid calling delete too early

Andelf 3 years ago
parent
commit
5c1ef22e8e
1 changed files with 4 additions and 1 deletions
  1. 4 1
      src/electron/electron/fs_watcher.cljs

+ 4 - 1
src/electron/electron/fs_watcher.cljs

@@ -82,8 +82,11 @@
              (fn [path]
                (publish-file-event! dir path "change")))
         (.on dir-watcher "unlink"
+             ;; delay 500ms for syncing disks
              (fn [path]
-               (publish-file-event! dir path "unlink")))
+               (js/setTimeout #(when (not (fs/existsSync path))
+                                 (publish-file-event! dir path "unlink"))
+                              500)))
         (.on dir-watcher "error"
              (fn [path]
                (println "Watch error happened: "