enhance: save files to logseq/bak when changes detected from the disk

This commit is contained in:
Tienson Qin
2021-09-22 18:13:54 +08:00
parent 9bc5bc94b7
commit 5d5d88f8df
2 changed files with 14 additions and 7 deletions

View File

@@ -55,14 +55,10 @@
(= (string/trim content) "-")
(= (string/trim content) "*")))
(p/let [
;; 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
:skip-compare? true})
_ (ipc/ipc "gitCommitAll" "Save the file from Logseq's database")
;; save the previous content in a bak file to avoid data overwritten.
_ (ipc/ipc "backupDbFile" (config/get-local-dir repo) path db-content)
_ (file-handler/alter-file repo path content {:re-render-root? true
:skip-compare? true})]
:from-disk? true})]
(set-missing-block-ids! content)
(db/set-file-last-modified-at! repo path mtime)))