mirror of https://github.com/logseq/logseq
parent
a28216c980
commit
42542aac23
|
@ -163,6 +163,24 @@
|
||||||
format ast properties
|
format ast properties
|
||||||
file content utf8-content journal?))))
|
file content utf8-content journal?))))
|
||||||
|
|
||||||
|
(defn with-block-uuid
|
||||||
|
[pages]
|
||||||
|
(->> (util/distinct-by :block/name pages)
|
||||||
|
(map (fn [page]
|
||||||
|
(if (:block/uuid page)
|
||||||
|
page
|
||||||
|
(assoc page :block/uuid (db/new-block-id)))))))
|
||||||
|
|
||||||
|
(defn with-ref-pages
|
||||||
|
[pages blocks]
|
||||||
|
(let [ref-pages (->> (mapcat :block/refs blocks)
|
||||||
|
(filter :block/name))]
|
||||||
|
(->> (concat pages ref-pages)
|
||||||
|
(group-by :block/name)
|
||||||
|
vals
|
||||||
|
(map (partial apply merge))
|
||||||
|
(with-block-uuid))))
|
||||||
|
|
||||||
(defn extract-all-blocks-pages
|
(defn extract-all-blocks-pages
|
||||||
[repo-url files metadata]
|
[repo-url files metadata]
|
||||||
(when (seq files)
|
(when (seq files)
|
||||||
|
@ -176,17 +194,7 @@
|
||||||
(remove empty?))]
|
(remove empty?))]
|
||||||
(when (seq result)
|
(when (seq result)
|
||||||
(let [[pages block-ids blocks] (apply map concat result)
|
(let [[pages block-ids blocks] (apply map concat result)
|
||||||
ref-pages (->> (mapcat :block/refs blocks)
|
pages (with-ref-pages pages blocks)
|
||||||
(filter :block/name))
|
|
||||||
pages (->> (concat pages ref-pages)
|
|
||||||
(group-by :block/name)
|
|
||||||
vals
|
|
||||||
(map (partial apply merge)))
|
|
||||||
pages (->> (util/distinct-by :block/name pages)
|
|
||||||
(map (fn [page]
|
|
||||||
(if (:block/uuid page)
|
|
||||||
page
|
|
||||||
(assoc page :block/uuid (db/new-block-id))))))
|
|
||||||
blocks (map (fn [block]
|
blocks (map (fn [block]
|
||||||
(let [id (:block/uuid block)
|
(let [id (:block/uuid block)
|
||||||
properties (get-in metadata [:block/properties id])]
|
properties (get-in metadata [:block/properties id])]
|
||||||
|
|
|
@ -142,7 +142,8 @@
|
||||||
file-content [{:file/path file}]
|
file-content [{:file/path file}]
|
||||||
tx (if (contains? config/mldoc-support-formats format)
|
tx (if (contains? config/mldoc-support-formats format)
|
||||||
(let [delete-blocks (db/delete-file-blocks! repo-url file)
|
(let [delete-blocks (db/delete-file-blocks! repo-url file)
|
||||||
[pages block-ids blocks] (extract-handler/extract-blocks-pages repo-url file content utf8-content)]
|
[pages block-ids blocks] (extract-handler/extract-blocks-pages repo-url file content utf8-content)
|
||||||
|
pages (extract-handler/with-ref-pages pages blocks)]
|
||||||
(concat file-content delete-blocks pages block-ids blocks))
|
(concat file-content delete-blocks pages block-ids blocks))
|
||||||
file-content)
|
file-content)
|
||||||
tx (concat tx [(let [t (tc/to-long (t/now))]
|
tx (concat tx [(let [t (tc/to-long (t/now))]
|
||||||
|
|
Loading…
Reference in New Issue