mirror of
https://github.com/logseq/logseq.git
synced 2026-06-01 19:01:22 +00:00
enhance(rtc): add logs for rtc-start
This commit is contained in:
@@ -105,37 +105,42 @@
|
||||
|
||||
(defn <rtc-start!
|
||||
[repo & {:keys [stop-before-start?] :or {stop-before-start? true}}]
|
||||
(when-let [graph-uuid (ldb/get-graph-rtc-uuid (db/get-db repo))]
|
||||
(p/do!
|
||||
(js/Promise. user-handler/task--ensure-id&access-token)
|
||||
(p/let [start-ex (state/<invoke-db-worker :thread-api/rtc-start stop-before-start?)
|
||||
ex-data* (ex-data start-ex)
|
||||
_ (case (:type ex-data*)
|
||||
(:rtc.exception/not-rtc-graph
|
||||
:rtc.exception/not-found-db-conn)
|
||||
(notification/show! (ex-message start-ex) :error)
|
||||
(let [db (db/get-db repo)
|
||||
graph-uuid (ldb/get-graph-rtc-uuid db)]
|
||||
(if-not graph-uuid
|
||||
(log/error :<rtc-start! ["graph-uuid not found" repo])
|
||||
(p/do!
|
||||
(js/Promise. user-handler/task--ensure-id&access-token)
|
||||
(p/let [start-ex (state/<invoke-db-worker :thread-api/rtc-start stop-before-start?)
|
||||
ex-data* (ex-data start-ex)
|
||||
_ (case (:type ex-data*)
|
||||
(:rtc.exception/not-rtc-graph
|
||||
:rtc.exception/not-found-db-conn)
|
||||
(notification/show! (ex-message start-ex) :error)
|
||||
|
||||
:rtc.exception/major-schema-version-mismatched
|
||||
(case (:sub-type ex-data*)
|
||||
:download
|
||||
(notification-download-higher-schema-graph! repo graph-uuid (:remote ex-data*))
|
||||
:create-branch
|
||||
(notification-upload-higher-schema-graph! repo)
|
||||
;; else
|
||||
(do (log/info :start-ex start-ex)
|
||||
(notification/show! [:div
|
||||
[:div (ex-message start-ex)]
|
||||
[:div (-> ex-data*
|
||||
(select-keys [:app :local :remote])
|
||||
pp/pprint
|
||||
with-out-str)]]
|
||||
:error)))
|
||||
:rtc.exception/major-schema-version-mismatched
|
||||
(case (:sub-type ex-data*)
|
||||
:download
|
||||
(notification-download-higher-schema-graph! repo graph-uuid (:remote ex-data*))
|
||||
:create-branch
|
||||
(notification-upload-higher-schema-graph! repo)
|
||||
;; else
|
||||
(do (log/info :start-ex start-ex)
|
||||
(notification/show! [:div
|
||||
[:div (ex-message start-ex)]
|
||||
[:div (-> ex-data*
|
||||
(select-keys [:app :local :remote])
|
||||
pp/pprint
|
||||
with-out-str)]]
|
||||
:error)))
|
||||
|
||||
:rtc.exception/lock-failed nil
|
||||
:rtc.exception/lock-failed nil
|
||||
|
||||
;; else
|
||||
nil)]
|
||||
nil))))
|
||||
;; else
|
||||
nil)]
|
||||
nil)))
|
||||
|
||||
))
|
||||
|
||||
(defn <get-remote-graphs
|
||||
[]
|
||||
|
||||
@@ -378,23 +378,28 @@
|
||||
(let [repo (worker-state/get-current-repo)
|
||||
token (worker-state/get-id-token)
|
||||
conn (worker-state/get-datascript-conn repo)]
|
||||
(when (and repo
|
||||
(sqlite-util/db-based-graph? repo)
|
||||
token conn)
|
||||
(when stop-before-start? (rtc-stop))
|
||||
(let [ex (m/? (new-task--rtc-start* repo token))]
|
||||
(when-let [ex-data* (ex-data ex)]
|
||||
(case (:type ex-data*)
|
||||
(:rtc.exception/not-rtc-graph
|
||||
:rtc.exception/major-schema-version-mismatched
|
||||
:rtc.exception/lock-failed)
|
||||
(log/info :rtc-start-failed ex)
|
||||
(if-not (and repo
|
||||
(sqlite-util/db-based-graph? repo)
|
||||
conn token)
|
||||
(log/error :new-task--rtc-start-failed
|
||||
{:repo repo
|
||||
:some?-conn (some? conn)
|
||||
:some?-token (some? token)})
|
||||
(do
|
||||
(when stop-before-start? (rtc-stop))
|
||||
(let [ex (m/? (new-task--rtc-start* repo token))]
|
||||
(when-let [ex-data* (ex-data ex)]
|
||||
(case (:type ex-data*)
|
||||
(:rtc.exception/not-rtc-graph
|
||||
:rtc.exception/major-schema-version-mismatched
|
||||
:rtc.exception/lock-failed)
|
||||
(log/info :rtc-start-failed ex)
|
||||
|
||||
:rtc.exception/not-found-db-conn
|
||||
(log/error :rtc-start-failed ex)
|
||||
:rtc.exception/not-found-db-conn
|
||||
(log/error :rtc-start-failed ex)
|
||||
|
||||
(log/error :BUG-unknown-error ex))
|
||||
ex))))))
|
||||
(log/error :BUG-unknown-error ex))
|
||||
ex)))))))
|
||||
|
||||
(defn rtc-stop
|
||||
[]
|
||||
|
||||
Reference in New Issue
Block a user