瀏覽代碼

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

rcmerci 2 年之前
父節點
當前提交
af3f4ecd32
共有 1 個文件被更改,包括 18 次插入18 次删除
  1. 18 18
      src/main/frontend/handler/file_sync.cljs

+ 18 - 18
src/main/frontend/handler/file_sync.cljs

@@ -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]
   []