fix: don't listen to unlink

Sometimes, the file watcher notify the `unlink` type when we edit a
file using another editor ...
pull/1274/head
Tienson Qin 2021-02-05 17:04:06 +08:00
parent d55b381e2e
commit 7dcebf368b
2 changed files with 15 additions and 15 deletions

View File

@ -115,11 +115,11 @@
:path (fix-win-path! path)
:content (read-file path)
:stat (fs/statSync path)})))
(.on watcher "unlink"
(fn [path]
(send-file-watcher! win "unlink"
{:dir (fix-win-path! dir)
:path (fix-win-path! path)})))
;; (.on watcher "unlink"
;; (fn [path]
;; (send-file-watcher! win "unlink"
;; {:dir (fix-win-path! dir)
;; :path (fix-win-path! path)})))
(.on watcher "error"
(fn [path]
(println "Watch error happened: "

View File

@ -40,16 +40,16 @@
(file-handler/alter-file repo path content {:re-render-root? true})
(= "unlink" type)
(when-let [page-name (db/get-file-page path)]
(page-handler/delete!
page-name
(fn []
(notification/show! (str "Page " page-name " was deleted on disk.")
:success)
(when (= (state/get-current-page) page-name)
;; redirect to home
(route-handler/redirect-to-home!)))))
;; (= "unlink" type)
;; (when-let [page-name (db/get-file-page path)]
;; (page-handler/delete!
;; page-name
;; (fn []
;; (notification/show! (str "Page " page-name " was deleted on disk.")
;; :success)
;; (when (= (state/get-current-page) page-name)
;; ;; redirect to home
;; (route-handler/redirect-to-home!)))))
(contains? #{"add" "change" "unlink"} type)
nil