mirror of https://github.com/logseq/logseq
debug: add more steps for debugging
parent
1b393d953d
commit
a2bb381b1c
|
@ -30,15 +30,16 @@
|
|||
(let [step (get-in @state/state [:debug/write-acks file-path :step])]
|
||||
(state/pub-event! [:instrument {:type :debug/write-failed
|
||||
:payload {:step step}}])
|
||||
(notification/show!
|
||||
(str "Logseq failed to save the page "
|
||||
page-title
|
||||
" to the file: "
|
||||
file-path
|
||||
". Stop editing this page anymore, and copy all the blocks of this page to another editor to avoid any data-loss.\n"
|
||||
"Last step: "
|
||||
step)
|
||||
:error)))))
|
||||
;; (notification/show!
|
||||
;; (str "Logseq failed to save the page "
|
||||
;; page-title
|
||||
;; " to the file: "
|
||||
;; file-path
|
||||
;; ". Stop editing this page anymore, and copy all the blocks of this page to another editor to avoid any data-loss.\n"
|
||||
;; "Last step: "
|
||||
;; step)
|
||||
;; :error)
|
||||
))))
|
||||
default-write-ack-timeout)]
|
||||
(swap! ack-wait-timeouts assoc file-path timeout)))))
|
||||
|
||||
|
|
|
@ -75,7 +75,6 @@
|
|||
(->
|
||||
(p/let [result (ipc/ipc "writeFile" path content)
|
||||
mtime (gobj/get result "mtime")]
|
||||
(prn "[DEBUG] 5. The file was saved successfully!" {:path path})
|
||||
(when (util/electron?)
|
||||
(debug/set-ack-step! path :saved-successfully)
|
||||
(debug/ack-file-write! path))
|
||||
|
@ -88,6 +87,9 @@
|
|||
(ok-handler repo path result))
|
||||
result)
|
||||
(p/catch (fn [error]
|
||||
(state/pub-event! [:instrument {:type :debug/write-failed
|
||||
:payload {:step :ipc-write-file
|
||||
:error error}}])
|
||||
(if error-handler
|
||||
(error-handler error)
|
||||
(log/error :write-file-failed error)))))))))
|
||||
|
|
|
@ -23,7 +23,8 @@
|
|||
[frontend.utf8 :as utf8]
|
||||
[frontend.util :as util]
|
||||
[lambdaisland.glogi :as log]
|
||||
[promesa.core :as p]))
|
||||
[promesa.core :as p]
|
||||
[frontend.debug :as debug]))
|
||||
|
||||
;; TODO: extract all git ops using a channel
|
||||
|
||||
|
@ -245,6 +246,7 @@
|
|||
(-> (p/let [_ (or
|
||||
(util/electron?)
|
||||
(nfs/check-directory-permission! repo))]
|
||||
(debug/set-ack-step! path :write-file)
|
||||
(fs/write-file! repo (config/get-repo-dir repo) path content
|
||||
{:old-content original-content}))
|
||||
(p/catch (fn [error]
|
||||
|
@ -291,9 +293,20 @@
|
|||
[]
|
||||
(let [chan (state/get-file-write-chan)]
|
||||
(async/go-loop []
|
||||
(let [args (async/<! chan)]
|
||||
(let [args (async/<! chan)
|
||||
files (second args)]
|
||||
|
||||
(doseq [path (map first files)]
|
||||
(debug/set-ack-step! path :start-write-file))
|
||||
|
||||
;; return a channel
|
||||
(<p! (apply alter-files-handler! args)))
|
||||
(try
|
||||
(<p! (apply alter-files-handler! args))
|
||||
(catch js/Error e
|
||||
(log/error :file/write-failed e)
|
||||
(state/pub-event! [:instrument {:type :debug/write-failed
|
||||
:payload {:step :start-to-write
|
||||
:error e}}]))))
|
||||
(recur))
|
||||
chan))
|
||||
|
||||
|
|
|
@ -96,7 +96,6 @@
|
|||
(assert (some? chan) "File write chan shouldn't be nil")
|
||||
(let [chan-callback (:chan-callback opts)]
|
||||
(async/put! chan [repo files opts])
|
||||
(prn "[DEBUG] 4. Pushed to the write channel")
|
||||
(doseq [file (map first files)]
|
||||
(debug/set-ack-step! file :pushed-to-channel))
|
||||
(when chan-callback
|
||||
|
|
|
@ -44,8 +44,7 @@
|
|||
editor-cursor (state/get-current-edit-block-and-position)
|
||||
meta (merge opts {:editor-cursor editor-cursor})
|
||||
rs (d/transact! conn txs meta)]
|
||||
(prn "[DEBUG] 1. Logseq DB transacted")
|
||||
(when-not config/test?
|
||||
(when-not config/test?
|
||||
(after-transact-pipelines rs))
|
||||
rs)
|
||||
(catch js/Error e
|
||||
|
|
|
@ -27,9 +27,6 @@
|
|||
(string/blank? (:block/content (first blocks)))
|
||||
(nil? (:block/file page-block)))
|
||||
(let [tree (tree/blocks->vec-tree blocks (:block/name page-block))]
|
||||
(prn "[DEBUG] 3. Block tree built" {:time (util/time-ms)})
|
||||
(let [path (:file/path (:block/file (db/entity page-db-id)))]
|
||||
(debug/set-ack-step! path :start-writing))
|
||||
(file/save-tree page-block tree)))))
|
||||
|
||||
(defn write-files!
|
||||
|
|
|
@ -15,11 +15,6 @@
|
|||
path (:file/path (:block/file page))
|
||||
page-title (or (:block/original-name page)
|
||||
(:block/name page))]
|
||||
(prn "[DEBUG] 2. Start writing file: "
|
||||
{:page-id (:db/id page)
|
||||
:page (:block/name page)
|
||||
:file path
|
||||
:time (util/time-ms)})
|
||||
(when (util/electron?)
|
||||
(debug/set-ack-step! path :start-writing)
|
||||
(debug/wait-for-write-ack! page-title path)))
|
||||
|
|
Loading…
Reference in New Issue