fix: delete page if its file was deleted

close #2962
This commit is contained in:
Tienson Qin
2021-11-16 18:22:40 +08:00
parent ab84fe7032
commit 45af02ee2a
2 changed files with 13 additions and 6 deletions

View File

@@ -7,6 +7,7 @@
[frontend.handler.editor :as editor]
[frontend.handler.extract :as extract]
[frontend.handler.file :as file-handler]
[frontend.handler.page :as page-handler]
[lambdaisland.glogi :as log]
[electron.ipc :as ipc]
[promesa.core :as p]
@@ -30,7 +31,7 @@
(let [repo (config/get-local-repo dir)
{:keys [mtime]} stat
db-content (or (db/get-file repo path) "")]
(when (and content
(when (and (or content (= type "unlink"))
(not (encrypt/content-encrypted? content))
(not (:encryption/graph-parsing? @state/state)))
(cond
@@ -64,6 +65,12 @@
(set-missing-block-ids! content)
(db/set-file-last-modified-at! repo path mtime)))
(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 #()))
(contains? #{"add" "change" "unlink"} type)
nil