enhance: commit the content in logseq when detecting any disk changes

This commit is contained in:
Tienson Qin
2021-09-06 08:46:30 +08:00
parent 2fdc601c15
commit bfe6a5d6cb
3 changed files with 12 additions and 21 deletions

View File

@@ -54,7 +54,12 @@
(not (string/blank? content))
(not= (string/trim content)
(string/trim (or (db/get-file repo path) ""))))
(p/let [result (ipc/ipc "gitCommitAll" "")
(p/let [db-content (or (db/get-file repo path) "")
;; save the previous content in Logseq first and commit it to avoid
;; any data-loss.
_ (file-handler/alter-file repo path db-content {:re-render-root? false
:reset? false})
result (ipc/ipc "gitCommitAll" "")
_ (file-handler/alter-file repo path content {:re-render-root? true
:from-disk? true})]
(set-missing-block-ids! content)