fix: disable editing when the graph's directory is renamed or deleted

related to #5549
This commit is contained in:
Tienson Qin
2022-06-06 18:05:48 +08:00
parent da51051c07
commit 781062a4ce
5 changed files with 63 additions and 25 deletions

View File

@@ -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))