mirror of
https://github.com/logseq/logseq.git
synced 2026-05-03 02:16:30 +00:00
enhance: backup files when there're differences between db and disk
Previously, files are backuped to logseq/bak when logseq detects there're differences between the db and disk. But it has two problems: 1. Only a few of users know `logseq/bak`, other users think that their data has been lost. 2. Files in the logseq/bak folder are never truncated. This PR backups old file in DB with timestamp suffixes instead of logesq/bak, and only keep the latest 10 versions of any changed file.
This commit is contained in:
@@ -33,8 +33,8 @@
|
||||
(defn- handle-add-and-change!
|
||||
[repo path content db-content mtime backup?]
|
||||
(p/let [
|
||||
;; save the previous content in a bak file to avoid data overwritten.
|
||||
_ (when backup? (ipc/ipc "backupDbFile" (config/get-local-dir repo) path db-content))
|
||||
;; save the previous content in a versioned bak file to avoid data overwritten.
|
||||
_ (when backup? (ipc/ipc "backupDbFile" (config/get-local-dir repo) path db-content content))
|
||||
_ (file-handler/alter-file repo path content {:re-render-root? true
|
||||
:from-disk? true})]
|
||||
(set-missing-block-ids! content)
|
||||
|
||||
Reference in New Issue
Block a user