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

enhance: full file graph import works from CLI

Also cleaned up naming, added docstrings and fixed a bug that
failed import hard when user didn't input any tag-classes or
property-classes
Gabriel Horner пре 1 година
родитељ
комит
345fd96e2a

+ 37 - 47
deps/graph-parser/script/db_import.cljs

@@ -12,65 +12,53 @@
             [babashka.cli :as cli]
             [logseq.graph-parser.exporter :as gp-exporter]
             [logseq.common.graph :as common-graph]
-            [logseq.common.config :as common-config]
             [logseq.tasks.db-graph.create-graph :as create-graph]
             [promesa.core :as p]))
 
-(defn- remove-hidden-files [dir config files]
-  (if (seq (:hidden config))
-    (->> files
-         (map #(assoc % ::rel-path (node-path/relative dir (:rpath %))))
-         ((fn [files] (common-config/remove-hidden-files files config ::rel-path)))
-         (map #(dissoc % ::rel-path)))
-    files))
-
 (defn- build-graph-files
-  "Given a graph directory, return absolute, allowed file paths and their contents in preparation
-   for parsing"
+  "Given a file graph directory, return all files including assets and adds relative paths
+   on ::rpath since paths are absolute by default and exporter needs relative paths for
+   some operations"
   [dir*]
   (let [dir (node-path/resolve dir*)]
     (->> (common-graph/get-files dir)
-         (mapv #(hash-map :rpath %)))))
+         (concat (when (fs/existsSync (node-path/join dir* "assets"))
+                   (common-graph/readdir (node-path/join dir* "assets"))))
+         (mapv #(hash-map :path %
+                          ::rpath (node-path/relative dir* %))))))
 
 (defn- <read-file
   [file]
-  (p/let [s (fsp/readFile (:rpath file))]
+  (p/let [s (fsp/readFile (:path file))]
     (str s)))
 
-(defn- build-import-options [conn config options]
-  (-> (gp-exporter/setup-import-options
-       @conn
-       {}
-       (select-keys options [:tag-classes :property-classes])
-       {:notify-user prn :macros (:macros config)})
-      (assoc-in [:extract-options :verbose] (:verbose options))))
-
 (defn- <copy-asset-file [file db-graph-dir file-graph-dir]
   (p/let [parent-dir (node-path/dirname
-                      (node-path/join db-graph-dir (node-path/relative file-graph-dir (:rpath file))))
+                      (node-path/join db-graph-dir (node-path/relative file-graph-dir (:path file))))
           _ (fsp/mkdir parent-dir #js {:recursive true})]
-    (fsp/copyFile (:rpath file) (node-path/join parent-dir (node-path/basename (:rpath file))))))
+    (fsp/copyFile (:path file) (node-path/join parent-dir (node-path/basename (:path file))))))
 
-(defn- import-file-graph-to-db [file-graph-dir db-graph-dir conn options]
-  (p/let [*files (build-graph-files file-graph-dir)
-          config-file (first (filter #(string/ends-with? (:rpath %) "logseq/config.edn") *files))
-          _ (assert config-file "No 'logseq/config.edn' found for file graph dir")
-          ;; TODO: Add :default-config option
-          config (gp-exporter/import-config-file! conn config-file <read-file {:notify-user prn})
-          files (remove-hidden-files file-graph-dir config *files)
-          import-options (build-import-options conn config options)
-          logseq-file? #(string/includes? (:rpath %) "logseq/")
-          asset-files (when (fs/existsSync (node-path/join file-graph-dir "assets"))
-                        (map #(hash-map :rpath %) (common-graph/readdir (node-path/join file-graph-dir "assets"))))
-          doc-files (remove logseq-file? files)
-          logseq-files (filter logseq-file? files)]
-    (println "Importing" (count files) "files ...")
-    (p/do!
-     (gp-exporter/import-logseq-files conn logseq-files <read-file {:notify-user prn})
-     (gp-exporter/import-from-asset-files! asset-files #(<copy-asset-file % db-graph-dir file-graph-dir) {:notify-user prn})
-     (gp-exporter/import-from-doc-files! conn doc-files <read-file import-options)
-     (gp-exporter/import-favorites-from-config-edn! conn conn config {})
-     (gp-exporter/import-class-properties conn conn))))
+(defn- import-file-graph-to-db
+  "Import a file graph dir just like UI does. However, unlike the UI the
+  exporter receives file maps containing keys :path and ::rpath since :path
+  are full paths"
+  [file-graph-dir db-graph-dir conn options]
+  (let [*files (build-graph-files file-graph-dir)
+        config-file (first (filter #(string/ends-with? (:path %) "logseq/config.edn") *files))
+        _ (assert config-file "No 'logseq/config.edn' found for file graph dir")
+        options (merge options
+                       {;; common options
+                        :rpath-key ::rpath
+                        :notify-user prn
+                        :<read-file <read-file
+                        ;; :set-ui-state prn
+                        ;; config file options
+                        ;; TODO: Add actual default
+                        :default-config {}
+                        ;; asset file options
+                        :<copy-asset (fn copy-asset [file]
+                                       (<copy-asset-file file db-graph-dir file-graph-dir))})]
+    (gp-exporter/export-file-graph conn conn config-file *files options)))
 
 (defn- resolve-path
   "If relative path, resolve with $ORIGINAL_PWD"
@@ -79,11 +67,13 @@
     path
     (node-path/join (or js/process.env.ORIGINAL_PWD ".") path)))
 
-(defn- import-files-to-db [file conn {:keys [files] :as options}]
-  (let [import-options (build-import-options conn {:macros {}} options)
-        files' (mapv #(hash-map :rpath %)
+(defn- import-files-to-db
+  "Import specific doc files for dev purposes"
+  [file conn {:keys [files] :as options}]
+  (let [doc-options (gp-exporter/build-doc-options conn {:macros {}} options)
+        files' (mapv #(hash-map :path %)
                      (into [file] (map resolve-path files)))]
-    (gp-exporter/import-from-doc-files! conn files' <read-file import-options)))
+    (gp-exporter/export-doc-files conn files' <read-file doc-options)))
 
 (def spec
   "Options spec"

+ 97 - 44
deps/graph-parser/src/logseq/graph_parser/exporter.cljs

@@ -1,10 +1,12 @@
 (ns logseq.graph-parser.exporter
-  "Exports a file graph to DB graph. Used by the File to DB graph importer"
+  "Exports a file graph to DB graph. Used by the File to DB graph importer and
+  by nbb-logseq CLIs"
   (:require [clojure.set :as set]
             [clojure.string :as string]
             [clojure.edn :as edn]
             [datascript.core :as d]
             [logseq.graph-parser.extract :as extract]
+            [logseq.common.path :as path]
             [logseq.common.util :as common-util]
             [logseq.common.config :as common-config]
             [logseq.db.frontend.content :as db-content]
@@ -636,54 +638,44 @@
         result (d/transact! conn tx')]
     result))
 
-;; UI facing fns
-;; =============
-
-(defn setup-import-options
-  [db config user-options {:keys [macros notify-user]}]
-  (cond-> {:extract-options {:date-formatter (common-config/get-date-formatter config)
-                             :user-config config
-                             :filename-format (or (:file/name-format config) :legacy)}
-           :user-options user-options
-           :page-tags-uuid (:block/uuid (d/entity db [:block/name "pagetags"]))
-           :import-state (new-import-state)
-           :macros (or macros (:macros config))}
-    notify-user
-    (assoc :notify-user notify-user)))
-
-(defn- import-doc-file
-  [{:keys [rpath idx] :as file} conn <read-file
-   {:keys [notify-user set-ui-state import-file]
+;; Higher level export fns
+;; =======================
+
+(defn- export-doc-file
+  [{:keys [path idx] :as file} conn <read-file
+   {:keys [notify-user set-ui-state export-file]
     :or {set-ui-state (constantly nil)
-         import-file (fn import-file [conn m opts]
+         export-file (fn export-file [conn m opts]
                        (add-file-to-db-graph conn (:file/path m) (:file/content m) opts))}
-    :as import-options}]
-  ;; (prn :import-doc-file rpath idx)
+    :as options}]
+  ;; (prn :export-doc-file path idx)
   (-> (p/let [_ (set-ui-state [:graph/importing-state :current-idx] (inc idx))
-              _ (set-ui-state [:graph/importing-state :current-page] rpath)
+              _ (set-ui-state [:graph/importing-state :current-page] path)
               content (<read-file file)
-              m {:file/path rpath :file/content content}]
-        (import-file conn m (dissoc import-options :set-ui-state :import-file))
+              m {:file/path path :file/content content}]
+        (export-file conn m (dissoc options :set-ui-state :export-file))
         ;; returning val results in smoother ui updates
         m)
       (p/catch (fn [error]
-                 (notify-user {:msg (str "Import failed on " (pr-str rpath) " with error:\n" error)
+                 (notify-user {:msg (str "Import failed on " (pr-str path) " with error:\n" error)
                                :level :error
-                               :ex-data {:path rpath :error error}})))))
+                               :ex-data {:path path :error error}})))))
 
-(defn import-from-doc-files!
+(defn export-doc-files
+  "Exports all user created files i.e. under journals/ and pages/.
+   Recommended to use build-doc-options and pass that as options"
   [conn *doc-files <read-file {:keys [notify-user set-ui-state]
                                :or {set-ui-state (constantly nil) notify-user prn}
-                               :as import-options}]
+                               :as options}]
   (set-ui-state [:graph/importing-state :total] (count *doc-files))
   (let [doc-files (mapv #(assoc %1 :idx %2)
                         ;; Sort files to ensure reproducible import behavior
-                        (sort-by :rpath *doc-files)
+                        (sort-by :path *doc-files)
                         (range 0 (count *doc-files)))]
-    (-> (p/loop [_file-map (import-doc-file (get doc-files 0) conn <read-file import-options)
+    (-> (p/loop [_file-map (export-doc-file (get doc-files 0) conn <read-file options)
                  i 0]
           (when-not (>= i (dec (count doc-files)))
-            (p/recur (import-doc-file (get doc-files (inc i)) conn <read-file import-options)
+            (p/recur (export-doc-file (get doc-files (inc i)) conn <read-file options)
                      (inc i))))
         (p/catch (fn [e]
                    (notify-user {:msg (str "Import has unexpected error:\n" e)
@@ -694,11 +686,12 @@
                         :file/content content
                         :file/last-modified-at (js/Date.)}]))
 
-(defn import-logseq-files
+(defn- export-logseq-files
+  "Exports files under logseq/"
   [repo-or-conn logseq-files <read-file {:keys [<save-file notify-user]
                                          :or {<save-file default-save-file}}]
-  (let [custom-css (first (filter #(string/ends-with? (:rpath %) "logseq/custom.css") logseq-files))
-        custom-js (first (filter #(string/ends-with? (:rpath %) "logseq/custom.js") logseq-files))]
+  (let [custom-css (first (filter #(string/ends-with? (:path %) "logseq/custom.css") logseq-files))
+        custom-js (first (filter #(string/ends-with? (:path %) "logseq/custom.js") logseq-files))]
     (-> (p/do!
          (when custom-css
            (-> (<read-file custom-css)
@@ -710,7 +703,7 @@
                    (notify-user {:msg (str "Import unexpectedly failed while reading logseq files:\n" error)
                                  :level :error}))))))
 
-(defn import-config-file!
+(defn- export-config-file
   [repo-or-conn config-file <read-file {:keys [<save-file notify-user default-config]
                                         :or {default-config {}
                                              <save-file default-save-file}}]
@@ -725,7 +718,7 @@
                                :ex-data {:error err}})
                  (edn/read-string default-config)))))
 
-(defn import-class-properties
+(defn- export-class-properties
   [conn repo-or-conn]
   (let [user-classes (->> (d/q '[:find (pull ?b [:db/id :block/name])
                                  :where [?b :block/type "class"]] @conn)
@@ -754,20 +747,23 @@
                  class-to-prop-uuids)]
     (ldb/transact! repo-or-conn tx)))
 
-(defn import-from-asset-files!
-  [*asset-files <copy-asset-file {:keys [notify-user]}]
+(defn- export-asset-files
+  "Exports files under assets/"
+  [*asset-files <copy-asset-file {:keys [notify-user set-ui-state]
+                                  :or {set-ui-state (constantly nil)}}]
   (let [asset-files (mapv #(assoc %1 :idx %2)
                           ;; Sort files to ensure reproducible import behavior
-                          (sort-by :rpath *asset-files)
+                          (sort-by :path *asset-files)
                           (range 0 (count *asset-files)))
-        copy-asset (fn copy-asset [{:keys [rpath] :as file}]
+        copy-asset (fn copy-asset [{:keys [path] :as file}]
                      (p/catch
                       (<copy-asset-file file)
                       (fn [error]
-                        (notify-user {:msg (str "Import failed on " (pr-str rpath) " with error:\n" error)
+                        (notify-user {:msg (str "Import failed on " (pr-str path) " with error:\n" error)
                                       :level :error
-                                      :ex-data {:path rpath :error error}}))))]
+                                      :ex-data {:path path :error error}}))))]
     (when (seq asset-files)
+      (set-ui-state [:graph/importing-state :current-page] "Asset files")
       (-> (p/loop [_ (copy-asset (get asset-files 0))
                    i 0]
             (when-not (>= i (dec (count asset-files)))
@@ -793,7 +789,7 @@
                    favorited-ids)]
     (ldb/transact! repo-or-conn tx)))
 
-(defn import-favorites-from-config-edn!
+(defn- export-favorites-from-config-edn
   [conn repo config {:keys [log-fn] :or {log-fn prn}}]
   (when-let [favorites (seq (:favorites config))]
     (p/do!
@@ -806,3 +802,60 @@
        (let [page-entity (d/entity @conn [:block/name common-config/favorites-page-name])]
          (insert-favorites repo favorited-ids (:db/id page-entity)))
        (log-fn :no-favorites-found {:favorites favorites})))))
+
+(defn build-doc-options
+  "Builds options for use with export-doc-files"
+  [conn config options]
+(-> {:extract-options {:date-formatter (common-config/get-date-formatter config)
+                       :user-config config
+                       :filename-format (or (:file/name-format config) :legacy)
+                       :verbose (:verbose options)}
+     :user-options (select-keys options [:tag-classes :property-classes])
+     :page-tags-uuid (:block/uuid (d/entity @conn [:block/name "pagetags"]))
+     :import-state (new-import-state)
+     :macros (or (:macros options) (:macros config))}
+    (merge (select-keys options [:set-ui-state :export-file :notify-user]))))
+
+(defn export-file-graph
+  "Main fn which exports a file graph given its files and imports them
+   into a DB graph. Files is expected to be a seq of maps with a :path key.
+   The user experiences this as an import so all user-facing messages are
+   described as import. options map contains the following keys:
+   * :set-ui-state - fn which updates ui to indicate progress of import
+   * :notify-user - fn which notifies user of important messages with a map
+     containing keys :msg, :level and optionally :ex-data when there is an error
+   * :log-fn - fn which logs developer messages
+   * :rpath-key - keyword used to get relative path in file map. Default to :path
+   * :<read-file - fn which reads a file across multiple steps
+   * :default-config - default config if config is unable to be read
+   * :<save-config-file - fn which saves a config file
+   * :<save-logseq-file - fn which saves a logseq file
+   * :<copy-asset - fn which copies asset file
+   
+   Note: See export-doc-files for additional options that are only for it"
+  [repo-or-conn conn config-file *files {:keys [<read-file <copy-asset rpath-key log-fn]
+                                 :or {rpath-key :path log-fn println}
+                                 :as options}]
+  (p/let [config (export-config-file
+                  repo-or-conn config-file <read-file
+                  (-> (select-keys options [:notify-user :default-config :<save-config-file])
+                      (set/rename-keys {:<save-config-file :<save-file})))]
+    (let [files (common-config/remove-hidden-files *files config rpath-key)
+          logseq-file? #(string/starts-with? (get % rpath-key) "logseq/")
+          doc-files (->> files
+                         (remove logseq-file?)
+                         (filter #(contains? #{"md" "org" "markdown" "edn"} (path/file-ext (:path %)))))
+          asset-files (filter #(string/starts-with? (get % rpath-key) "assets/") files)
+          doc-options (build-doc-options conn config options)]
+      (log-fn "Importing" (count files) "files ...")
+      ;; These export* fns are all the major export/import steps
+      (p/do!
+       (export-logseq-files repo-or-conn (filter logseq-file? files) <read-file
+                            (-> (select-keys options [:notify-user :<save-logseq-file])
+                                (set/rename-keys {:<save-logseq-file :<save-file})))
+       (export-asset-files asset-files <copy-asset (select-keys options [:notify-user :set-ui-state]))
+       (export-doc-files conn doc-files <read-file doc-options)
+       (export-favorites-from-config-edn conn repo-or-conn config {})
+       (export-class-properties conn repo-or-conn)
+       {:import-state (:import-state doc-options)
+        :files files}))))

+ 46 - 65
src/main/frontend/components/imports.cljs

@@ -1,8 +1,6 @@
 (ns frontend.components.imports
   "Import data into Logseq."
-  (:require [cljs.core.async.interop :refer [p->c]]
-            [clojure.core.async :as async]
-            [clojure.string :as string]
+  (:require [clojure.string :as string]
             [cljs-time.core :as t]
             [cljs.pprint :as pprint]
             [frontend.components.onboarding.setups :as setups]
@@ -29,7 +27,6 @@
             [logseq.graph-parser.exporter :as gp-exporter]
             [promesa.core :as p]
             [rum.core :as rum]
-            [logseq.common.config :as common-config]
             [logseq.shui.ui :as shui]
             [lambdaisland.glogi :as log]
             [logseq.db.frontend.validate :as db-validate]))
@@ -231,8 +228,8 @@
 
 (defn- validate-imported-data
   [db import-state files]
-  (when-let [org-files (seq (filter #(= "org" (path/file-ext (:rpath %))) files))]
-    (log/info :org-files (mapv :rpath org-files))
+  (when-let [org-files (seq (filter #(= "org" (path/file-ext (:path %))) files))]
+    (log/info :org-files (mapv :path org-files))
     (notification/show! (str "Imported " (count org-files) " org file(s) as markdown. Support for org files will be added later.")
                         :info false))
   (when-let [ignored-props (seq @(:ignored-properties import-state))]
@@ -274,68 +271,52 @@
         (log/error :import-error ex-data)))
     (notification/show! msg :warning false)))
 
+(defn- copy-asset [repo repo-dir file]
+  (-> (.arrayBuffer (:file-object file))
+      (p/then (fn [buffer]
+                (let [content (js/Uint8Array. buffer)
+                      parent-dir (path/path-join repo-dir (path/dirname (:path file)))]
+                  (p/do!
+                   (fs/mkdir-if-not-exists parent-dir)
+                   (fs/write-file! repo repo-dir (:path file) content {:skip-transact? true})))))))
+
 (defn- import-file-graph
   [*files {:keys [graph-name tag-classes property-classes]} config-file]
   (state/set-state! :graph/importing :file-graph)
   (state/set-state! [:graph/importing-state :current-page] "Config files")
-  (async/go
-    (let [start-time (t/now)
-          _ (async/<! (p->c (repo-handler/new-db! graph-name {:file-graph-import? true})))
+  (p/let [start-time (t/now)
+          _ (repo-handler/new-db! graph-name {:file-graph-import? true})
           repo (state/get-current-repo)
           db-conn (db/get-db repo false)
-          <read-file (fn [file] (.text (:file-object file)))
-          config (async/<! (p->c (gp-exporter/import-config-file!
-                                  repo config-file <read-file
-                                  {:notify-user show-notification
-                                   :default-config config/config-default-content
-                                   :<save-file (fn [_ path content]
-                                                 (let [migrated-content (repo-handler/migrate-db-config content)]
-                                                   (db-editor-handler/save-file! path migrated-content)))})))
-          files (common-config/remove-hidden-files *files config :rpath)
-          logseq-file? #(string/starts-with? (:rpath %) "logseq/")
-          doc-files (->> files
-                         (remove logseq-file?)
-                         (filter #(contains? #{"md" "org" "markdown" "edn"} (path/file-ext (:rpath %)))))
-          asset-files (filter #(string/starts-with? (:rpath %) "assets/") files)
-          import-options (merge
-                          (gp-exporter/setup-import-options
-                           @db-conn
-                           config
-                           {:tag-classes (set (string/split tag-classes #",\s*"))
-                            :property-classes (set (string/split property-classes #",\s*"))}
-                           {:macros (:macros config)
-                            :notify-user show-notification})
-                          {:set-ui-state state/set-state!
-                           ;; Write to frontend first as writing to worker first is poor ux with slow streaming changes
-                           :import-file (fn import-file [conn m opts]
-                                          (let [tx-report
-                                                (gp-exporter/add-file-to-db-graph conn (:file/path m) (:file/content m) opts)]
-                                            (db-browser/transact! @db-browser/*worker repo (:tx-data tx-report) (:tx-meta tx-report))))})
-          repo-dir (config/get-repo-dir repo)
-          <copy-asset (fn copy-asset [file]
-                        (-> (.arrayBuffer (:file-object file))
-                            (p/then (fn [buffer]
-                                      (let [content (js/Uint8Array. buffer)
-                                            parent-dir (path/path-join repo-dir (path/dirname (:rpath file)))]
-                                        (p/do!
-                                         (fs/mkdir-if-not-exists parent-dir)
-                                         (fs/write-file! repo repo-dir (:rpath file) content {:skip-transact? true})))))))]
-      (async/<! (p->c (gp-exporter/import-logseq-files (state/get-current-repo)
-                                                       (filter logseq-file? files)
-                                                       <read-file
-                                                       {:<save-file (fn [_ path content]
-                                                                      (db-editor-handler/save-file! path content))
-                                                        :notify-user show-notification})))
-      (state/set-state! [:graph/importing-state :current-page] "Asset files")
-      (async/<! (p->c (gp-exporter/import-from-asset-files! asset-files <copy-asset {:notify-user show-notification})))
-      (async/<! (p->c (gp-exporter/import-from-doc-files! db-conn doc-files <read-file import-options)))
-      (async/<! (p->c (gp-exporter/import-favorites-from-config-edn! db-conn repo config {})))
-      (async/<! (p->c (gp-exporter/import-class-properties db-conn repo)))
-      (log/info :import-file-graph {:msg (str "Import finished in " (/ (t/in-millis (t/interval start-time (t/now))) 1000) " seconds")})
-      (state/set-state! :graph/importing nil)
-      (state/set-state! :graph/importing-state nil)
-      (validate-imported-data @db-conn (:import-state import-options) files)
-      (finished-cb))))
+          options {;; user options
+                   :tag-classes (set (string/split tag-classes #",\s*"))
+                   :property-classes (set (string/split property-classes #",\s*"))
+                   ;; common options
+                   :notify-user show-notification
+                   :set-ui-state state/set-state!
+                   :<read-file (fn <read-file [file] (.text (:file-object file)))
+                   ;; config file options
+                   :default-config config/config-default-content
+                   :<save-config-file (fn save-config-file [_ path content]
+                                        (let [migrated-content (repo-handler/migrate-db-config content)]
+                                          (db-editor-handler/save-file! path migrated-content)))
+                   ;; logseq file options
+                   :<save-logseq-file (fn save-logseq-file [_ path content]
+                                        (db-editor-handler/save-file! path content))
+                   ;; asset file options
+                   :<copy-asset #(copy-asset repo (config/get-repo-dir repo) %)
+                   ;; doc file options
+                   ;; Write to frontend first as writing to worker first is poor ux with slow streaming changes
+                   :export-file (fn export-file [conn m opts]
+                                  (let [tx-report
+                                        (gp-exporter/add-file-to-db-graph conn (:file/path m) (:file/content m) opts)]
+                                    (db-browser/transact! @db-browser/*worker repo (:tx-data tx-report) (:tx-meta tx-report))))}
+          {:keys [files import-state]} (gp-exporter/export-file-graph repo db-conn config-file *files options)]
+    (log/info :import-file-graph {:msg (str "Import finished in " (/ (t/in-millis (t/interval start-time (t/now))) 1000) " seconds")})
+    (state/set-state! :graph/importing nil)
+    (state/set-state! :graph/importing-state nil)
+    (validate-imported-data @db-conn import-state files)
+    (finished-cb)))
 
 (defn import-file-to-db-handler
   "Import from a graph folder as a DB-based graph.
@@ -347,11 +328,11 @@
         import-graph-fn (fn [user-inputs]
                           (let [files (->> file-objs
                                            (map #(hash-map :file-object %
-                                                           :rpath (path/trim-dir-prefix original-graph-name (.-webkitRelativePath %))))
-                                           (remove #(and (not (string/starts-with? (:rpath %) "assets/"))
+                                                           :path (path/trim-dir-prefix original-graph-name (.-webkitRelativePath %))))
+                                           (remove #(and (not (string/starts-with? (:path %) "assets/"))
                                                          ;; TODO: Update this when supporting more formats as this aggressively excludes most formats
                                                          (fs-util/ignored-path? original-graph-name (.-webkitRelativePath (:file-object %))))))]
-                            (if-let [config-file (first (filter #(= (:rpath %) "logseq/config.edn") files))]
+                            (if-let [config-file (first (filter #(= (:path %) "logseq/config.edn") files))]
                               (import-file-graph files user-inputs config-file)
                               (notification/show! "Import failed as the file 'logseq/config.edn' was not found for a Logseq graph."
                                                   :error))))]