From adef15d07349d5199a800115e3a7e6923b540021 Mon Sep 17 00:00:00 2001 From: rcmerci Date: Fri, 12 May 2023 11:30:54 +0800 Subject: [PATCH] fix(sync): validate rsapi upload err when localtime incorrect, aws s3 return "Request is not yet valid" err --- src/main/frontend/dicts.cljc | 5 ++++- src/main/frontend/fs/sync.cljs | 11 ++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/frontend/dicts.cljc b/src/main/frontend/dicts.cljc index 5869b543b..1a47a746f 100644 --- a/src/main/frontend/dicts.cljc +++ b/src/main/frontend/dicts.cljc @@ -371,6 +371,8 @@ :file-sync/other-user-graph "Current local graph is bound to other user's remote graph. So can't start syncing." :file-sync/graph-deleted "The current remote graph has been deleted" + :file-sync/rsapi-cannot-upload-err "Unable to start synchronization, please check if the local time is correct." + :notification/clear-all "Clear all"} @@ -763,7 +765,7 @@ :right-side-bar/history "(Dev) Verlauf rückgängig machen / wiederherstellen" :select/default-select-multiple "Ein oder mehrere auswählen" :settings-page/auto-expand-block-refs "Automatisch beim Heranzoomen Blockreferenzen erweitern..." - + :whiteboard/link-whiteboard-or-block "Whiteboard/Seite/Block verknüpfen"} :nl { :all-files "Alle bestanden" @@ -1683,6 +1685,7 @@ :file-sync/other-user-graph "当前本地图谱绑定在其他用户的远程图谱上。因此无法启动同步。" :file-sync/graph-deleted "当前远程图谱已经删除" + :file-sync/rsapi-cannot-upload-err "无法同步,请检查本机时间是否准确" :notification/clear-all "清除全部通知"} diff --git a/src/main/frontend/fs/sync.cljs b/src/main/frontend/fs/sync.cljs index 3cd60b98a..c332f4a57 100644 --- a/src/main/frontend/fs/sync.cljs +++ b/src/main/frontend/fs/sync.cljs @@ -1680,6 +1680,10 @@ [r] (some->> (ex-cause r) str (re-find #"graph-not-exist"))) +(defn- stop-sync-by-rsapi-response? + [r] + (some->> (ex-cause r) str (re-find #"Request is not yet valid"))) + ;; type = "change" | "add" | "unlink" (deftype FileChangeEvent [type dir path stat checksum] @@ -2594,10 +2598,15 @@ (do (println :graph-has-been-deleted r*) {:graph-has-been-deleted true}) + (stop-sync-by-rsapi-response? r*) + (do (println :stop-sync-caused-by-rsapi-err-response r*) + (notification/show! (t :file-sync/rsapi-cannot-upload-err) :warning false) + {:stop true}) + paused? {:pause true} - succ? ; succ + succ? ; succ (do (println "sync-local->remote! update txid" r*) ;; persist txid