mirror of
https://github.com/logseq/logseq.git
synced 2026-05-24 04:34:14 +00:00
enhance(cli): increase timeout for 'sync upload'
This commit is contained in:
@@ -83,6 +83,7 @@
|
||||
|
||||
(def ^:private sync-start-timeout-ms 10000)
|
||||
(def ^:private sync-start-poll-interval-ms 1000)
|
||||
(def ^:private sync-upload-timeout-ms (* 30 60 1000))
|
||||
(def ^:private sync-download-timeout-ms (* 30 60 1000))
|
||||
|
||||
(def ^:private sync-start-skipped-states
|
||||
@@ -133,6 +134,11 @@
|
||||
(when (seq (some-> line str string/trim))
|
||||
(println line)))
|
||||
|
||||
(defn- sync-upload-invoke-config
|
||||
[cfg]
|
||||
(assoc cfg :timeout-ms (max 0 (or (:sync-upload-timeout-ms cfg)
|
||||
sync-upload-timeout-ms))))
|
||||
|
||||
(defn- sync-download-invoke-config
|
||||
[cfg]
|
||||
(assoc cfg :timeout-ms (max 0 (or (:sync-download-timeout-ms cfg)
|
||||
@@ -580,9 +586,10 @@
|
||||
(defn- execute-sync-upload
|
||||
[action config]
|
||||
(-> (p/let [cfg (cli-server/ensure-server! config (:repo action))
|
||||
upload-cfg (sync-upload-invoke-config cfg)
|
||||
_ (<sync-worker-runtime! cfg config)
|
||||
_ (<verify-and-save-e2ee-password-on-worker-if-provided! cfg config action)
|
||||
result (transport/invoke cfg :thread-api/db-sync-upload-graph [(:repo action)])]
|
||||
_ (<verify-and-save-e2ee-password-on-worker-if-provided! upload-cfg config action)
|
||||
result (transport/invoke upload-cfg :thread-api/db-sync-upload-graph [(:repo action)])]
|
||||
{:status :ok
|
||||
:data (if (map? result)
|
||||
result
|
||||
|
||||
@@ -633,17 +633,21 @@
|
||||
(deftest test-execute-sync-upload
|
||||
(async done
|
||||
(let [ensure-calls (atom [])
|
||||
invoke-calls (atom [])]
|
||||
invoke-calls (atom [])
|
||||
invoke-timeouts (atom [])]
|
||||
(-> (p/with-redefs [cli-server/ensure-server! (fn [config repo]
|
||||
(swap! ensure-calls conj [config repo])
|
||||
(p/resolved (assoc config :base-url "http://example")))
|
||||
transport/invoke (fn [_ method args]
|
||||
transport/invoke (fn [cfg method args]
|
||||
(swap! invoke-calls conj [method args])
|
||||
(swap! invoke-timeouts conj [method (:timeout-ms cfg)])
|
||||
(p/resolved {:ok true}))]
|
||||
(p/let [_ (execute-with-runtime-auth {:type :sync-upload
|
||||
:repo "logseq_db_demo"}
|
||||
{:root-dir "/tmp"})]
|
||||
{:root-dir "/tmp"
|
||||
:timeout-ms 10000})]
|
||||
(is (= [[{:root-dir "/tmp"
|
||||
:timeout-ms 10000
|
||||
:id-token "runtime-token"}
|
||||
"logseq_db_demo"]]
|
||||
@ensure-calls))
|
||||
@@ -654,7 +658,9 @@
|
||||
:http-base nil}]]
|
||||
(second @invoke-calls)))
|
||||
(is (= [:thread-api/db-sync-upload-graph ["logseq_db_demo"]]
|
||||
(nth @invoke-calls 2)))))
|
||||
(nth @invoke-calls 2)))
|
||||
(is (= [:thread-api/db-sync-upload-graph 1800000]
|
||||
(nth @invoke-timeouts 2)))))
|
||||
(p/catch (fn [e]
|
||||
(is false (str "unexpected error: " e))))
|
||||
(p/finally done)))))
|
||||
|
||||
Reference in New Issue
Block a user