Преглед на файлове

fix: block/alias failing partial exports

e.g. ontology and page exports. Also remove unused fn option
Gabriel Horner преди 6 месеца
родител
ревизия
7c38daef24
променени са 1 файла, в които са добавени 7 реда и са изтрити 8 реда
  1. 7 8
      deps/db/src/logseq/db/sqlite/export.cljs

+ 7 - 8
deps/db/src/logseq/db/sqlite/export.cljs

@@ -160,8 +160,7 @@
 (defn- build-export-class
 (defn- build-export-class
   "The caller of this fn is responsible for building any classes or properties from this fn
   "The caller of this fn is responsible for building any classes or properties from this fn
    unless shallow-copy?"
    unless shallow-copy?"
-  [class-ent {:keys [include-parents? include-uuid? shallow-copy? include-timestamps?]
-              :or {include-parents? true}}]
+  [class-ent {:keys [include-uuid? shallow-copy? include-timestamps? include-alias?]}]
   (cond-> (select-keys class-ent [:block/title :block/collapsed?])
   (cond-> (select-keys class-ent [:block/title :block/collapsed?])
     include-uuid?
     include-uuid?
     (assoc :block/uuid (:block/uuid class-ent) :build/keep-uuid? true)
     (assoc :block/uuid (:block/uuid class-ent) :build/keep-uuid? true)
@@ -170,11 +169,10 @@
     (and (:logseq.property.class/properties class-ent) (not shallow-copy?))
     (and (:logseq.property.class/properties class-ent) (not shallow-copy?))
     (assoc :build/class-properties
     (assoc :build/class-properties
            (mapv :db/ident (:logseq.property.class/properties class-ent)))
            (mapv :db/ident (:logseq.property.class/properties class-ent)))
-    (and (not shallow-copy?) (:block/alias class-ent))
+    (and (not shallow-copy?) include-alias? (:block/alias class-ent))
     (assoc :block/alias (set (map #(vector :block/uuid (:block/uuid %)) (:block/alias class-ent))))
     (assoc :block/alias (set (map #(vector :block/uuid (:block/uuid %)) (:block/alias class-ent))))
     ;; It's caller's responsibility to ensure parent is included in final export
     ;; It's caller's responsibility to ensure parent is included in final export
-    (and include-parents?
-         (not shallow-copy?)
+    (and (not shallow-copy?)
          (:logseq.property/parent class-ent)
          (:logseq.property/parent class-ent)
          (not= :logseq.class/Root (:db/ident (:logseq.property/parent class-ent))))
          (not= :logseq.class/Root (:db/ident (:logseq.property/parent class-ent))))
     (assoc :build/class-parent
     (assoc :build/class-parent
@@ -418,7 +416,7 @@
     (merge {::block (:node node-export)}
     (merge {::block (:node node-export)}
            block-export)))
            block-export)))
 
 
-(defn- build-page-blocks-export [db page-entity {:keys [properties classes blocks ontology-page?] :as options}]
+(defn- build-page-blocks-export [db page-entity {:keys [properties classes blocks ontology-page? include-alias?] :as options}]
   (let [options' (cond-> (dissoc options :classes :blocks :graph-ontology)
   (let [options' (cond-> (dissoc options :classes :blocks :graph-ontology)
                    (:exclude-ontology? options)
                    (:exclude-ontology? options)
                    (assoc :properties (get-in options [:graph-ontology :properties])))
                    (assoc :properties (get-in options [:graph-ontology :properties])))
@@ -431,7 +429,7 @@
                (:node page-ent-export)
                (:node page-ent-export)
                (merge (dissoc (:node page-ent-export) :block/title)
                (merge (dissoc (:node page-ent-export) :block/title)
                       (shallow-copy-page page-entity)
                       (shallow-copy-page page-entity)
-                      (when (:block/alias page-entity)
+                      (when (and include-alias? (:block/alias page-entity))
                         {:block/alias (set (map #(vector :block/uuid (:block/uuid %)) (:block/alias page-entity)))})))
                         {:block/alias (set (map #(vector :block/uuid (:block/uuid %)) (:block/alias page-entity)))})))
         page-blocks-export {:pages-and-blocks [{:page page :blocks blocks}]
         page-blocks-export {:pages-and-blocks [{:page page :blocks blocks}]
                             :properties properties
                             :properties properties
@@ -675,7 +673,8 @@
    * :exclude-built-in-pages? - When set, built-in pages are excluded from export
    * :exclude-built-in-pages? - When set, built-in pages are excluded from export
    * :exclude-files? - When set, files are excluded from export"
    * :exclude-files? - When set, files are excluded from export"
   [db {:keys [exclude-files?] :as options*}]
   [db {:keys [exclude-files?] :as options*}]
-  (let [options (merge options* {:property-value-uuids? true})
+  (let [options (merge options* {:property-value-uuids? true
+                                 :include-alias? true})
         content-ref-uuids (get-graph-content-ref-uuids db options)
         content-ref-uuids (get-graph-content-ref-uuids db options)
         ontology-options (merge options {:include-uuid? true})
         ontology-options (merge options {:include-uuid? true})
         ontology-export (build-graph-ontology-export db ontology-options)
         ontology-export (build-graph-ontology-export db ontology-options)