mirror of https://github.com/logseq/logseq
refactor: alert when file in the db is not equal to the file on the disk
parent
d3f88d8b66
commit
f696b5ca73
|
@ -105,8 +105,7 @@
|
||||||
(and local-file (.text local-file)))))
|
(and local-file (.text local-file)))))
|
||||||
|
|
||||||
(write-file! [this repo dir path content opts]
|
(write-file! [this repo dir path content opts]
|
||||||
(let [{:keys [old-content]} opts
|
(let [last-modified-at (db/get-file-last-modified-at repo path)
|
||||||
last-modified-at (db/get-file-last-modified-at repo path)
|
|
||||||
parts (string/split path "/")
|
parts (string/split path "/")
|
||||||
basename (last parts)
|
basename (last parts)
|
||||||
sub-dir (->> (butlast parts)
|
sub-dir (->> (butlast parts)
|
||||||
|
@ -135,32 +134,26 @@
|
||||||
(config/get-file-format))
|
(config/get-file-format))
|
||||||
pending-writes (state/get-write-chan-length)
|
pending-writes (state/get-write-chan-length)
|
||||||
draw? (and path (string/ends-with? path ".excalidraw"))]
|
draw? (and path (string/ends-with? path ".excalidraw"))]
|
||||||
|
(p/let [_ (verify-permission repo file-handle true)
|
||||||
|
_ (utils/writeFile file-handle content)
|
||||||
|
file (.getFile file-handle)]
|
||||||
|
(if (and local-content new?
|
||||||
|
(or
|
||||||
|
draw?
|
||||||
|
;; Writing not finished
|
||||||
|
(> pending-writes 0)
|
||||||
|
;; not changed by other editors
|
||||||
|
not-changed?
|
||||||
|
new-created?))
|
||||||
(do
|
(do
|
||||||
(p/let [_ (verify-permission repo file-handle true)
|
(p/let [_ (verify-permission repo file-handle true)
|
||||||
_ (utils/writeFile file-handle content)
|
_ (utils/writeFile file-handle content)
|
||||||
file (.getFile file-handle)]
|
file (.getFile file-handle)]
|
||||||
(when file
|
(when file
|
||||||
(nfs-saved-handler repo path file))))
|
(nfs-saved-handler repo path file))))
|
||||||
;; (if (and local-content (or old-content
|
(do
|
||||||
;; ;; temporally fix
|
(js/alert (str "The file has been modified on your local disk! File path: " path
|
||||||
;; draw?) new?
|
", please save your changes and click the refresh button to reload it."))))))
|
||||||
;; (or
|
|
||||||
;; draw?
|
|
||||||
;; ;; Writing not finished
|
|
||||||
;; (> pending-writes 0)
|
|
||||||
;; ;; not changed by other editors
|
|
||||||
;; not-changed?
|
|
||||||
;; new-created?))
|
|
||||||
;; (do
|
|
||||||
;; (p/let [_ (verify-permission repo file-handle true)
|
|
||||||
;; _ (utils/writeFile file-handle content)
|
|
||||||
;; file (.getFile file-handle)]
|
|
||||||
;; (when file
|
|
||||||
;; (nfs-saved-handler repo path file))))
|
|
||||||
;; (do
|
|
||||||
;; (js/alert (str "The file has been modified on your local disk! File path: " path
|
|
||||||
;; ", please save your changes and click the refresh button to reload it."))))
|
|
||||||
)
|
|
||||||
;; create file handle
|
;; create file handle
|
||||||
(->
|
(->
|
||||||
(p/let [handle (idb/get-item handle-path)]
|
(p/let [handle (idb/get-item handle-path)]
|
||||||
|
|
|
@ -27,8 +27,7 @@
|
||||||
[repo dir path content {:keys [ok-handler error-handler] :as opts} stat]
|
[repo dir path content {:keys [ok-handler error-handler] :as opts} stat]
|
||||||
(p/let [disk-mtime (when stat (gobj/get stat "mtime"))
|
(p/let [disk-mtime (when stat (gobj/get stat "mtime"))
|
||||||
db-mtime (db/get-file-last-modified-at repo path)]
|
db-mtime (db/get-file-last-modified-at repo path)]
|
||||||
(if false
|
(if (not= disk-mtime db-mtime)
|
||||||
;; (not= disk-mtime db-mtime)
|
|
||||||
(js/alert (str "The file has been modified on your local disk! File path: " path
|
(js/alert (str "The file has been modified on your local disk! File path: " path
|
||||||
", please save your changes and click the refresh button to reload it."))
|
", please save your changes and click the refresh button to reload it."))
|
||||||
(->
|
(->
|
||||||
|
|
Loading…
Reference in New Issue