Преглед изворни кода

fix: cannot download file from all-files page

Weihua Lu пре 4 година
родитељ
комит
230e3c49de
1 измењених фајлова са 16 додато и 7 уклоњено
  1. 16 7
      src/main/frontend/handler/export.cljs

+ 16 - 7
src/main/frontend/handler/export.cljs

@@ -35,13 +35,22 @@
 
 (defn- get-file-content
   [file-path]
-  (let [page-name
-        (ffirst (d/q '[:find ?pn
-                       :where
-                       [?e :file/path file-path]
-                       [?p :block/file ?e]
-                       [?p :block/name ?pn]] (db/get-conn)))]
-    (get-page-content page-name)))
+  (if-let [page-name
+           (ffirst (d/q '[:find ?pn
+                          :in $ ?path
+                          :where
+                          [?p :block/file ?f]
+                          [?p :block/name ?pn]
+                          [?f :file/path ?path]]
+                        (db/get-conn) file-path))]
+    (get-page-content page-name)
+    (ffirst
+     (d/q '[:find ?content
+            :in $ ?path
+            :where
+            [?f :file/path ?path]
+            [?f :file/content ?content]]
+          (db/get-conn) file-path))))
 
 (defn- get-blocks-contents
   [repo root-block-uuid]