mirror of
https://github.com/logseq/logseq.git
synced 2026-05-05 03:16:37 +00:00
enhance: re-enable file watcher when the folder is back
By following the great suggestions from https://github.com/hakon-j-d-johnsen.
This commit is contained in:
@@ -8,13 +8,15 @@
|
||||
[frontend.handler.page :as page-handler]
|
||||
[frontend.handler.repo :as repo-handler]
|
||||
[frontend.handler.ui :as ui-handler]
|
||||
[frontend.handler.notification :as notification]
|
||||
[logseq.graph-parser.util :as gp-util]
|
||||
[frontend.util.text :as text-util]
|
||||
[lambdaisland.glogi :as log]
|
||||
[electron.ipc :as ipc]
|
||||
[promesa.core :as p]
|
||||
[frontend.state :as state]
|
||||
[frontend.encrypt :as encrypt]))
|
||||
[frontend.encrypt :as encrypt]
|
||||
[frontend.fs :as fs]))
|
||||
|
||||
;; all IPC paths must be normalized! (via gp-util/path-normalize)
|
||||
|
||||
@@ -61,7 +63,14 @@
|
||||
(state/update-state! :file/unlinked-dirs (fn [dirs] (conj dirs dir))))
|
||||
|
||||
(= "addDir" type)
|
||||
(state/update-state! :file/unlinked-dirs (fn [dirs] (disj dirs dir)))
|
||||
(when (contains? (:file/unlinked-dirs @state/state) dir)
|
||||
(notification/clear-all!)
|
||||
(state/pub-event! [:notification/show
|
||||
{:content (str "The directory " dir " has been back, you can edit your graph now.")
|
||||
:status :success
|
||||
:clear? true}])
|
||||
(fs/watch-dir! dir)
|
||||
(state/update-state! :file/unlinked-dirs (fn [dirs] (disj dirs dir))))
|
||||
|
||||
(contains? (:file/unlinked-dirs @state/state) dir)
|
||||
nil
|
||||
@@ -90,9 +99,11 @@
|
||||
|
||||
(and (= "unlink" type)
|
||||
(db/file-exists? repo path))
|
||||
(when-let [page-name (db/get-file-page path)]
|
||||
(println "Delete page: " page-name ", file path: " path ".")
|
||||
(page-handler/delete! page-name #() :unlink-file? true))
|
||||
(p/let [dir-exists? (fs/file-exists? dir "")]
|
||||
(when dir-exists?
|
||||
(when-let [page-name (db/get-file-page path)]
|
||||
(println "Delete page: " page-name ", file path: " path ".")
|
||||
(page-handler/delete! page-name #() :unlink-file? true))))
|
||||
|
||||
(and (contains? #{"add" "change" "unlink"} type)
|
||||
(string/ends-with? path "logseq/custom.css"))
|
||||
|
||||
Reference in New Issue
Block a user