enhance(asset-sync): download missing assets when starting asset-sync-loop

This commit is contained in:
rcmerci
2024-11-15 21:13:59 +08:00
committed by Tienson Qin
parent 8f7f1fc31d
commit 78734af1c2
4 changed files with 48 additions and 4 deletions

View File

@@ -216,7 +216,8 @@
(defn <get-all-assets
[]
(when-let [path (config/get-current-repo-assets-root)]
(p/let [result (fs/readdir path {:path-only? true})]
(p/let [result (p/catch (fs/readdir path {:path-only? true})
(fn [_e] nil))]
(p/all (map (fn [path]
(p/let [data (fs/read-file path "" {})]
(let [path' (util/node-path.join "assets" (util/node-path.basename path))]
@@ -235,6 +236,12 @@
(p/let [[repo-dir assets-dir] (ensure-assets-dir! (state/get-current-repo))]
(path/path-join repo-dir assets-dir filename)))
(defn <get-all-asset-file-paths
[repo]
(when-let [path (config/get-repo-assets-root repo)]
(p/catch (fs/readdir path {:path-only? true})
(fn [_e] nil))))
(defn <read-asset
[repo asset-block-id asset-type]
(let [asset-block-id-str (str asset-block-id)