mirror of
https://github.com/logseq/logseq.git
synced 2026-06-01 19:01:22 +00:00
fix(regression): re-index a file graph causes loading issues
when switching back to the graph
This commit is contained in:
@@ -235,8 +235,7 @@
|
||||
(state/pub-event! [:graph/open-new-window url])
|
||||
(cond
|
||||
;; exists locally?
|
||||
(or (:root graph)
|
||||
(and db-only? (not rtc-graph?)))
|
||||
(or (:root graph) (not rtc-graph?))
|
||||
(state/pub-event! [:graph/switch url])
|
||||
|
||||
(and rtc-graph? remote?)
|
||||
|
||||
@@ -8,20 +8,20 @@
|
||||
[frontend.fs :as fs]
|
||||
[frontend.fs.nfs :as nfs]
|
||||
[frontend.handler.common :as common-handler]
|
||||
[frontend.handler.file-based.repo :as file-repo-handler]
|
||||
[frontend.handler.global-config :as global-config-handler]
|
||||
[frontend.handler.repo :as repo-handler]
|
||||
[frontend.handler.file-based.repo :as file-repo-handler]
|
||||
[frontend.handler.route :as route-handler]
|
||||
[frontend.idb :as idb]
|
||||
[frontend.mobile.util :as mobile-util]
|
||||
[frontend.persist-db :as persist-db]
|
||||
[frontend.state :as state]
|
||||
[frontend.util :as util]
|
||||
[frontend.util.fs :as util-fs]
|
||||
[goog.object :as gobj]
|
||||
[lambdaisland.glogi :as log]
|
||||
[logseq.common.util :as common-util]
|
||||
[promesa.core :as p]
|
||||
[frontend.persist-db :as persist-db]))
|
||||
[promesa.core :as p]))
|
||||
|
||||
(defn remove-ignore-files
|
||||
[files dir-name nfs?]
|
||||
@@ -89,7 +89,7 @@
|
||||
(defn ls-dir-files-with-handler!
|
||||
"Read files from directory and setup repo (for the first time setup a repo)"
|
||||
([ok-handler] (ls-dir-files-with-handler! ok-handler nil))
|
||||
([ok-handler {:keys [on-open-dir dir-result-fn picked-root-fn dir]}]
|
||||
([ok-handler {:keys [on-open-dir dir-result-fn picked-root-fn dir re-index?]}]
|
||||
(let [electron? (util/electron?)
|
||||
mobile-native? (mobile-util/native-platform?)
|
||||
nfs? (and (not electron?)
|
||||
@@ -128,7 +128,7 @@
|
||||
[:notification/show
|
||||
{:content (str "This graph already exists in \"" (:root exists-graph) "\"")
|
||||
:status :warning}])
|
||||
(p/do! (persist-db/<new repo {})
|
||||
(p/do! (persist-db/<new repo {:op (if re-index? :re-index :add-file-graph)})
|
||||
(repo-handler/start-repo-db-if-not-exists! repo)
|
||||
(when (config/global-config-enabled?)
|
||||
(global-config-handler/restore-global-config!))
|
||||
@@ -273,7 +273,7 @@
|
||||
(when repo
|
||||
(p/do!
|
||||
(repo-handler/remove-repo! {:url repo} :switch-graph? false)
|
||||
(ls-dir-files-with-path! graph-dir)
|
||||
(ls-dir-files-with-path! graph-dir {:re-index? true})
|
||||
(when (fn? ok-handler) (ok-handler))))))
|
||||
|
||||
;; TODO: move to frontend.handler.repo
|
||||
|
||||
@@ -881,7 +881,7 @@
|
||||
;; because shared-service operates at the graph level,
|
||||
;; creating a new database or switching to another one requires re-initializing the service.
|
||||
(let [[graph opts] (ldb/read-transit-str (last args))]
|
||||
(if (:import-type opts)
|
||||
(if (or (:import-type opts) (= (:op opts) :add-file-graph))
|
||||
(start-db! graph opts)
|
||||
(p/let [service (<init-service! graph)]
|
||||
(get-in service [:status :ready])
|
||||
|
||||
Reference in New Issue
Block a user