Explorar o código

fix(fs): missing create default files

Andelf %!s(int64=2) %!d(string=hai) anos
pai
achega
783c6f1737
Modificáronse 2 ficheiros con 13 adicións e 13 borrados
  1. 12 11
      src/main/frontend/handler/repo.cljs
  2. 1 2
      src/main/frontend/handler/web/nfs.cljs

+ 12 - 11
src/main/frontend/handler/repo.cljs

@@ -119,13 +119,13 @@
   [repo-url]
   (spec/validate :repos/url repo-url)
   (let [repo-dir (config/get-repo-dir repo-url)]
-    (p/let [_ (fs/mkdir-if-not-exists (util/safe-path-join repo-dir config/app-name))
-            _ (fs/mkdir-if-not-exists (util/safe-path-join repo-dir (str config/app-name "/" config/recycle-dir)))
-            _ (fs/mkdir-if-not-exists (util/safe-path-join repo-dir (config/get-journals-directory)))
-            _ (repo-config-handler/create-config-file-if-not-exists repo-url)
-            _ (create-contents-file repo-url)
-            _ (create-custom-theme repo-url)]
-      (state/pub-event! [:page/create-today-journal repo-url]))))
+    (p/do! (fs/mkdir-if-not-exists (path/path-join repo-dir config/app-name))
+           (fs/mkdir-if-not-exists (path/path-join repo-dir config/app-name config/recycle-dir))
+           (fs/mkdir-if-not-exists (path/path-join repo-dir (config/get-journals-directory)))
+           (repo-config-handler/create-config-file-if-not-exists repo-url)
+           (create-contents-file repo-url)
+           (create-custom-theme repo-url)
+           (state/pub-event! [:page/create-today-journal repo-url]))))
 
 (defonce *file-tx (atom nil))
 
@@ -276,10 +276,11 @@
         _ (state/set-config! repo-url config)
         ;; remove :hidden files from file-objs, :hidden
         file-objs (common-handler/remove-hidden-files file-objs config :file/path)]
-    (if (seq file-objs)
-      (parse-files-and-load-to-db! repo-url file-objs {:new-graph? new-graph?
-                                                       :empty-graph? empty-graph?})
-      (state/set-parsing-state! {:graph-loading? false}))))
+
+    ;; Load to db even it's empty, (will create default files)
+    (parse-files-and-load-to-db! repo-url file-objs {:new-graph? new-graph?
+                                                     :empty-graph? empty-graph?})
+    (state/set-parsing-state! {:graph-loading? false})))
 
 
 

+ 1 - 2
src/main/frontend/handler/web/nfs.cljs

@@ -95,8 +95,7 @@
          mobile-native? (mobile-util/native-platform?)
          nfs? (and (not electron?)
                    (not mobile-native?))
-         *repo (atom nil)
-         dir (or dir nil)]
+         *repo (atom nil)]
      ;; TODO: add ext filter to avoid loading .git or other ignored file handlers
      (->
       (p/let [_ (prn :xxx-dir-result-fn dir-result-fn)