From 7f7e21cdcef81370fb6a4e3a0d99aef583eaae3e Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Fri, 28 Oct 2022 19:33:16 +0800 Subject: [PATCH] fix: progressing number when downloading files --- src/main/frontend/components/file_sync.cljs | 8 +-- src/main/frontend/fs/sync.cljs | 57 ++++++++++++++------- 2 files changed, 41 insertions(+), 24 deletions(-) diff --git a/src/main/frontend/components/file_sync.cljs b/src/main/frontend/components/file_sync.cljs index 0b65793f4..4ccb77fd4 100644 --- a/src/main/frontend/components/file_sync.cljs +++ b/src/main/frontend/components/file_sync.cljs @@ -217,12 +217,8 @@ full-upload-files (:full-local->remote-files sync-state) full-download-files (:full-remote->local-files sync-state) calc-progress-total #(cond - uploading? (if (zero? (count full-upload-files)) - (count uploading-files) - (count full-upload-files)) - downloading? (if (zero? (count full-download-files)) - (count downloading-files) - (count full-download-files)) + uploading? (count full-upload-files) + downloading? (count full-download-files) :else 0) calc-progress-finished (fn [] (let [current-sync-files (set diff --git a/src/main/frontend/fs/sync.cljs b/src/main/frontend/fs/sync.cljs index e07415d6a..7a7a1183d 100644 --- a/src/main/frontend/fs/sync.cljs +++ b/src/main/frontend/fs/sync.cljs @@ -461,6 +461,15 @@ (contains-path? (relative-path path)) (boolean))) +(defn- diffs->filetxns + [] + (comp + (map diff->filetxns) + cat + (remove ignored?) + distinct-update-filetxns-xf + remove-deleted-filetxns-xf)) + (defn- diffs->partitioned-filetxns "transducer. 1. diff -> `FileTxn` , see also `local-files) (defn apply-filetxns-partitions "won't call local-file-items (filetxns=>recent-remote->local-files filetxns) + _ (when-not full-sync? + (swap! *sync-state #(sync-state-reset-full-remote->local-files % recent-remote->local-file-items))) ;; update recent-remote->local-files _ (swap! *sync-state sync-state--add-recent-remote->local-files recent-remote->local-file-items) @@ -2148,13 +2160,15 @@ :epoch (tc/to-epoch (t/now))}}) (local-files % [])) + (local-files % files)) (put-sync-event! {:event :start :data {:type :remote->local :graph-uuid graph-uuid :full-sync? false :epoch (tc/to-epoch (t/now))}}) (if (empty? (flatten partitioned-filetxns)) - (do (local-files % [])) + (remote-all-files!-result r) (cond succ - (do (put-sync-event! {:event :finished-local->remote - :data {:graph-uuid graph-uuid - :full-sync? true - :epoch (tc/to-epoch (t/now))}}) - (.schedule this ::idle nil nil)) + (do + (swap! *sync-state #(sync-state-reset-full-local->remote-files % [])) + (put-sync-event! {:event :finished-local->remote + :data {:graph-uuid graph-uuid + :full-sync? true + :epoch (tc/to-epoch (t/now))}}) + (.schedule this ::idle nil nil)) need-sync-remote (do (util/drain-chan ops-chan) (>! ops-chan {:remote->local true}) @@ -2811,12 +2830,14 @@ (or need-sync-remote graph-has-been-deleted unknown pause stop) r))))] (cond succ - (do (put-sync-event! {:event :finished-local->remote - :data {:graph-uuid graph-uuid - :full-sync? false - :file-change-events distincted-local-changes - :epoch (tc/to-epoch (t/now))}}) - (.schedule this ::idle nil nil)) + (do + (swap! *sync-state #(sync-state-reset-full-local->remote-files % [])) + (put-sync-event! {:event :finished-local->remote + :data {:graph-uuid graph-uuid + :full-sync? false + :file-change-events distincted-local-changes + :epoch (tc/to-epoch (t/now))}}) + (.schedule this ::idle nil nil)) need-sync-remote (do (util/drain-chan ops-chan)