From 1f7269182b7642858a6c15ea14c0f6435b26c065 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Mon, 5 Sep 2022 10:33:37 +0800 Subject: [PATCH 1/2] fix: remove tricky check --- src/main/frontend/fs/sync.cljs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/main/frontend/fs/sync.cljs b/src/main/frontend/fs/sync.cljs index 1511d4ae7a..4419c52035 100644 --- a/src/main/frontend/fs/sync.cljs +++ b/src/main/frontend/fs/sync.cljs @@ -1544,14 +1544,15 @@ [type {:keys [dir path _content stat] :as _payload}] (when-let [current-graph (state/get-current-repo)] (when (string/ends-with? current-graph dir) - (when-not (sync-state--stopped? (state/get-file-sync-state current-graph)) - (when (or (:mtime stat) (= type "unlink")) - (go - (let [path (remove-dir-prefix dir path) - files-meta (and (not= "unlink" type) - ( files-meta first :etag))] - (>! local-changes-chan (->FileChangeEvent type dir path stat checksum))))))))) + (let [sync-state (state/get-file-sync-state current-graph)] + (when (and sync-state (not (sync-state--stopped? sync-state))) + (when (or (:mtime stat) (= type "unlink")) + (go + (let [path (remove-dir-prefix dir path) + files-meta (and (not= "unlink" type) + ( files-meta first :etag))] + (>! local-changes-chan (->FileChangeEvent type dir path stat checksum)))))))))) (defn local-changes-revised-chan-builder "return chan" @@ -1975,9 +1976,9 @@ add-history? (update :history add-history-items paths now)))) (defn sync-state--stopped? - "Graph syncing is stopped or not enabled" + "Graph syncing is stopped" [sync-state] - (or (nil? sync-state) (= ::stop (:state sync-state)))) + (= ::stop (:state sync-state))) ;;; ### remote->local syncer & local->remote syncer From 86c18bd70689adec79f876c273e4908b8421589b Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Mon, 5 Sep 2022 11:09:33 +0800 Subject: [PATCH 2/2] fix: add pre condition for sync-state --- src/main/frontend/fs/sync.cljs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/frontend/fs/sync.cljs b/src/main/frontend/fs/sync.cljs index 4419c52035..25e5baf999 100644 --- a/src/main/frontend/fs/sync.cljs +++ b/src/main/frontend/fs/sync.cljs @@ -1978,6 +1978,7 @@ (defn sync-state--stopped? "Graph syncing is stopped" [sync-state] + {:pre [(s/valid? ::sync-state sync-state)]} (= ::stop (:state sync-state))) ;;; ### remote->local syncer & local->remote syncer