From 681c3e421ebaca5c4aa693bd56481db23be6ccf5 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Thu, 29 Sep 2022 19:45:37 +0800 Subject: [PATCH] fix: cancel previous requests when sync needs to download/upload This can avoid running multiple downloads/uploads at the same time. --- src/main/frontend/components/file_sync.cljs | 3 --- src/main/frontend/fs/sync.cljs | 9 +++++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/frontend/components/file_sync.cljs b/src/main/frontend/components/file_sync.cljs index 9687d77b9c..a778e3e6e4 100644 --- a/src/main/frontend/components/file_sync.cljs +++ b/src/main/frontend/components/file_sync.cljs @@ -500,9 +500,6 @@ ;; options {:outer-header [:<> - (ui/button "stop syncing" - :on-click (fn [] - (fs-sync/rsapi-cancel-all-requests))) (when (util/electron?) (indicator-progress-pane sync-state sync-progress diff --git a/src/main/frontend/fs/sync.cljs b/src/main/frontend/fs/sync.cljs index 3455f2d91e..c3a4ad91c5 100644 --- a/src/main/frontend/fs/sync.cljs +++ b/src/main/frontend/fs/sync.cljs @@ -719,6 +719,8 @@ (recur (dec n))) r)))) +(declare rsapi-cancel-all-requests) + (deftype RSAPI [^:mutable graph-uuid' ^:mutable private-key' ^:mutable public-key'] IToken (c (ipc/ipc "update-local-files" graph-uuid base-path filepaths token)))))) (c (ipc/ipc "update-remote-files" graph-uuid base-path filepaths local-txid token))))))) @@ -948,8 +952,9 @@ nil)) (defn rsapi-cancel-all-requests [] - (when rsapi - (go (