diff --git a/bb.edn b/bb.edn index 1b2cdee83..5a9adbe11 100644 --- a/bb.edn +++ b/bb.edn @@ -8,7 +8,9 @@ {:git/url "https://github.com/logseq/bb-tasks" :git/sha "4b3e623fb475cacb992425aa9dac770d6dd63e38"} logseq/graph-parser - {:local/root "deps/graph-parser"}} + {:local/root "deps/graph-parser"} + org.clj-commons/digest + {:mvn/version "1.4.100"}} :pods {clj-kondo/clj-kondo {:version "2022.02.09"} org.babashka/fswatcher {:version "0.0.3"}} diff --git a/scripts/src/logseq/tasks/file_sync.clj b/scripts/src/logseq/tasks/file_sync.clj index 03badd064..4bbf614fd 100644 --- a/scripts/src/logseq/tasks/file_sync.clj +++ b/scripts/src/logseq/tasks/file_sync.clj @@ -12,6 +12,7 @@ [babashka.curl :as curl] [clojure.data :as data] [clojure.test :as t :refer [deftest is]] + [clj-commons.digest :as digest] [logseq.tasks.file-sync-actions :as file-sync-actions]) (:import (java.net URLDecoder))) @@ -55,7 +56,14 @@ body (json/parse-string (:body resp) keyword)] (->> body :Objects - (map (comp #(URLDecoder/decode %) fs/file-name :Key))))) + (map (juxt (comp #(URLDecoder/decode %) fs/file-name :Key) :checksum))))) + +(defn- get-local-all-files + [dir subdir] + (let [files (map fs/file (fs/list-dir (fs/file dir subdir))) + f (juxt fs/file-name digest/md5)] + (map f files))) + (defn- api-post-get-graphs [] @@ -95,14 +103,14 @@ (spit (fs/file dir file) new-content))) (defn run-action [action-map] - (println "==\nRUN") + (println "===\nRUN") (pp/pprint ((juxt :action #(get-in % [:args :file])) action-map)) (println "===") (run-action* action-map)) (defn- ensure-dir-is-synced! [dir graph-id subdir] - (let [actual (set (map fs/file-name (fs/list-dir (fs/file dir subdir)))) + (let [actual (set (get-local-all-files dir subdir)) expected (set (api-get-all-files graph-id subdir))] (assert (= actual expected) (let [[local-only remote-only _] (data/diff actual expected)] @@ -163,7 +171,7 @@ (doseq [actions partitioned-actions] (doseq [action actions] (run-action action) - (Thread/sleep 500)) + (Thread/sleep 1000)) (is (wait&files-are-in-sync? @root-dir @root-graph-id subdir) (str "Test " (mapv (juxt :action #(get-in % [:args :file])) actions))))))