浏览代码

fix(watcher): avoid calling delete too early

Andelf 3 年之前
父节点
当前提交
5c1ef22e8e
共有 1 个文件被更改,包括 4 次插入1 次删除
  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: "