mirror of https://github.com/logseq/logseq
enhance: don't overwrite logseq's file if changes from journal file
is empty or the default template content. To prevent overwritten when using iCloud/OneDrive/GDrive.pull/2830/head 0.3.9
parent
f5cdfaa2f1
commit
f59f59b9ae
|
@ -9,7 +9,8 @@
|
|||
[frontend.handler.file :as file-handler]
|
||||
[lambdaisland.glogi :as log]
|
||||
[electron.ipc :as ipc]
|
||||
[promesa.core :as p]))
|
||||
[promesa.core :as p]
|
||||
[frontend.state :as state]))
|
||||
|
||||
(defn- set-missing-block-ids!
|
||||
[content]
|
||||
|
@ -46,6 +47,13 @@
|
|||
(and (= "change" type)
|
||||
(not= (string/trim content) (string/trim db-content))
|
||||
(not (string/includes? path "logseq/pages-metadata.edn")))
|
||||
(when-not (and
|
||||
(string/includes? path (str "/" (config/get-journals-directory) "/"))
|
||||
(or
|
||||
(= (string/trim content)
|
||||
(string/trim (or (state/get-default-journal-template) "")))
|
||||
(= (string/trim content) "-")
|
||||
(= (string/trim content) "*")))
|
||||
(p/let [
|
||||
;; save the previous content in Logseq first and commit it to avoid
|
||||
;; any data-loss.
|
||||
|
@ -56,7 +64,7 @@
|
|||
_ (file-handler/alter-file repo path content {:re-render-root? true
|
||||
:skip-compare? true})]
|
||||
(set-missing-block-ids! content)
|
||||
(db/set-file-last-modified-at! repo path mtime))
|
||||
(db/set-file-last-modified-at! repo path mtime)))
|
||||
|
||||
(contains? #{"add" "change" "unlink"} type)
|
||||
nil
|
||||
|
|
|
@ -100,7 +100,7 @@
|
|||
title (date/today)
|
||||
file-name (date/journal-title->default title)
|
||||
default-content (util/default-content-with-title format)
|
||||
template (state/get-journal-template)
|
||||
template (state/get-default-journal-template)
|
||||
template (when (and template
|
||||
(not (string/blank? template)))
|
||||
template)
|
||||
|
|
|
@ -969,11 +969,6 @@
|
|||
([path]
|
||||
(get-in @state [:ui/paths-scroll-positions path] 0)))
|
||||
|
||||
(defn get-journal-template
|
||||
[]
|
||||
(when-let [repo (get-current-repo)]
|
||||
(get-in @state [:config repo :default-templates :journals])))
|
||||
|
||||
(defn set-today!
|
||||
[value]
|
||||
(set-state! :today value))
|
||||
|
|
Loading…
Reference in New Issue