fix: fs/readdir return no-such-dir exception

This commit is contained in:
rcmerci
2022-12-13 16:54:03 +08:00
committed by Tienson Qin
parent 6bfa722cd9
commit af3f4ecd32

View File

@@ -143,25 +143,25 @@
(#(js->clj % :keywordize-keys true))
((juxt :dir :name))
(apply path/join base-path))
version-file-paths (->> (<! (p->c (fs/readdir version-files-dir :path-only? true)))
(remove #{version-files-dir}))]
version-file-paths (<! (p->c (fs/readdir version-files-dir :path-only? true)))]
(when-not (instance? ExceptionInfo version-file-paths)
(when (seq version-file-paths)
(->>
(mapv
(fn [path]
(try
(let [create-time
(-> (path/parse path)
(js->clj :keywordize-keys true)
:name
(#(tf/parse (tf/formatter "yyyy-MM-dd'T'HH_mm_ss.SSSZZ") %)))]
{:create-time create-time :path path :relative-path (string/replace-first path base-path "")})
(catch :default e
(log/error :page-history/parse-format-error e)
nil)))
version-file-paths)
(remove nil?))))))))
(let [version-file-paths (remove #{version-files-dir} version-file-paths)]
(when (seq version-file-paths)
(->>
(mapv
(fn [path]
(try
(let [create-time
(-> (path/parse path)
(js->clj :keywordize-keys true)
:name
(#(tf/parse (tf/formatter "yyyy-MM-dd'T'HH_mm_ss.SSSZZ") %)))]
{:create-time create-time :path path :relative-path (string/replace-first path base-path "")})
(catch :default e
(log/error :page-history/parse-format-error e)
nil)))
version-file-paths)
(remove nil?)))))))))
(defn fetch-page-file-versions [graph-uuid page]
[]