mirror of
https://github.com/logseq/logseq.git
synced 2026-05-05 03:16:37 +00:00
fix: disable editing when the graph's directory is renamed or deleted
related to #5549
This commit is contained in:
@@ -48,10 +48,24 @@
|
||||
pages-metadata-path (config/get-pages-metadata-path)
|
||||
{:keys [mtime]} stat
|
||||
db-content (or (db/get-file repo path) "")]
|
||||
(when (and (or content (= type "unlink"))
|
||||
(when (and (or content (contains? #{"unlink" "unlinkDir" "addDir"} type))
|
||||
(not (encrypt/content-encrypted? content))
|
||||
(not (:encryption/graph-parsing? @state/state)))
|
||||
(cond
|
||||
(and (= "unlinkDir" type) dir)
|
||||
(do
|
||||
(state/pub-event! [:notification/show
|
||||
{:content (str "The directory " dir " has been renamed or deleted, the editor will be disabled for this graph, you can unlink the graph.")
|
||||
:status :error
|
||||
:clear? false}])
|
||||
(state/update-state! :file/unlinked-dirs (fn [dirs] (conj dirs dir))))
|
||||
|
||||
(= "addDir" type)
|
||||
(state/update-state! :file/unlinked-dirs (fn [dirs] (disj dirs dir)))
|
||||
|
||||
(contains? (:file/unlinked-dirs @state/state) dir)
|
||||
nil
|
||||
|
||||
(and (= "add" type)
|
||||
(not= (string/trim content) (string/trim db-content))
|
||||
(not= path pages-metadata-path))
|
||||
|
||||
Reference in New Issue
Block a user