fix: new db graph shouldn't have deprecated config.edn warnings

pull/10981/head
Gabriel Horner 2024-01-30 15:12:51 -05:00
parent faa5e43966
commit 9db7cd3be9
3 changed files with 17 additions and 12 deletions

View File

@ -1,7 +1,6 @@
(ns frontend.components.imports (ns frontend.components.imports
"Import data into Logseq." "Import data into Logseq."
(:require [borkdude.rewrite-edn :as rewrite] (:require [cljs.core.async.interop :refer [p->c]]
[cljs.core.async.interop :refer [p->c]]
[clojure.core.async :as async] [clojure.core.async :as async]
[clojure.edn :as edn] [clojure.edn :as edn]
[clojure.string :as string] [clojure.string :as string]
@ -13,7 +12,6 @@
[frontend.context.i18n :refer [t]] [frontend.context.i18n :refer [t]]
[frontend.db :as db] [frontend.db :as db]
[frontend.fs :as fs] [frontend.fs :as fs]
[frontend.handler.common.config-edn :as config-edn-common-handler]
[frontend.handler.db-based.editor :as db-editor-handler] [frontend.handler.db-based.editor :as db-editor-handler]
[frontend.handler.import :as import-handler] [frontend.handler.import :as import-handler]
[frontend.handler.notification :as notification] [frontend.handler.notification :as notification]
@ -219,10 +217,7 @@
(-> (when config-file (-> (when config-file
(.text config-file)) (.text config-file))
(p/then (fn [content] (p/then (fn [content]
(let [migrated-content (-> (reduce rewrite/dissoc (let [migrated-content (repo-handler/migrate-db-config content)]
(rewrite/parse-string (str content))
(keys config-edn-common-handler/file-only-config))
str)]
(p/do! (p/do!
(db-editor-handler/save-file! "logseq/config.edn" migrated-content)) (db-editor-handler/save-file! "logseq/config.edn" migrated-content))
(edn/read-string migrated-content)))))) (edn/read-string migrated-content))))))

View File

@ -103,8 +103,9 @@ nested keys or positional errors e.g. tuples"
:block-hidden-properties :block-hidden-properties
"is not used in DB graphs as hiding a property is done in its configuration" "is not used in DB graphs as hiding a property is done in its configuration"
:ignored-page-references-keywords :ignored-page-references-keywords
"is not used in DB graphs" ;; TODO: Remove key when default is changed
:file/name-format ;; "is not used in DB graphs"
;; :file/name-format
"is not used in DB graphs" "is not used in DB graphs"
:feature/enable-block-timestamps? :feature/enable-block-timestamps?
"is not used in DB graphs as it is always enabled"}) "is not used in DB graphs as it is always enabled"})

View File

@ -11,6 +11,7 @@
[frontend.fs.nfs :as nfs] [frontend.fs.nfs :as nfs]
[frontend.handler.file :as file-handler] [frontend.handler.file :as file-handler]
[frontend.handler.repo-config :as repo-config-handler] [frontend.handler.repo-config :as repo-config-handler]
[frontend.handler.common.config-edn :as config-edn-common-handler]
[frontend.handler.common.file :as file-common-handler] [frontend.handler.common.file :as file-common-handler]
[frontend.handler.route :as route-handler] [frontend.handler.route :as route-handler]
[frontend.handler.ui :as ui-handler] [frontend.handler.ui :as ui-handler]
@ -35,7 +36,8 @@
[clojure.core.async :as async] [clojure.core.async :as async]
[frontend.mobile.util :as mobile-util] [frontend.mobile.util :as mobile-util]
[medley.core :as medley] [medley.core :as medley]
[logseq.common.path :as path])) [logseq.common.path :as path]
[borkdude.rewrite-edn :as rewrite]))
;; Project settings should be checked in two situations: ;; Project settings should be checked in two situations:
;; 1. User changes the config.edn directly in logseq.com (fn: alter-file) ;; 1. User changes the config.edn directly in logseq.com (fn: alter-file)
@ -104,7 +106,7 @@
:else :else
default-content) default-content)
file-rpath (path/path-join (config/get-journals-directory) (str file-name "." file-rpath (path/path-join (config/get-journals-directory) (str file-name "."
(config/get-file-extension format))) (config/get-file-extension format)))
page-exists? (db/entity repo-url [:block/name (util/page-name-sanity-lc title)]) page-exists? (db/entity repo-url [:block/name (util/page-name-sanity-lc title)])
empty-blocks? (db/page-empty? repo-url (util/page-name-sanity-lc title))] empty-blocks? (db/page-empty? repo-url (util/page-name-sanity-lc title))]
(when (or empty-blocks? (not page-exists?)) (when (or empty-blocks? (not page-exists?))
@ -518,13 +520,20 @@
(let [full-graph-name (string/lower-case (str config/db-version-prefix graph-name))] (let [full-graph-name (string/lower-case (str config/db-version-prefix graph-name))]
(some #(= (some-> (:url %) string/lower-case) full-graph-name) (state/get-repos)))) (some #(= (some-> (:url %) string/lower-case) full-graph-name) (state/get-repos))))
(defn migrate-db-config
[content]
(-> (reduce rewrite/dissoc
(rewrite/parse-string (str content))
(keys config-edn-common-handler/file-only-config))
str))
(defn- create-db [full-graph-name {:keys [file-graph-import?]}] (defn- create-db [full-graph-name {:keys [file-graph-import?]}]
(-> (->
(p/let [_ (persist-db/<new full-graph-name) (p/let [_ (persist-db/<new full-graph-name)
_ (start-repo-db-if-not-exists! full-graph-name) _ (start-repo-db-if-not-exists! full-graph-name)
_ (state/add-repo! {:url full-graph-name}) _ (state/add-repo! {:url full-graph-name})
_ (when-not file-graph-import? (route-handler/redirect-to-home!)) _ (when-not file-graph-import? (route-handler/redirect-to-home!))
initial-data (sqlite-create-graph/build-db-initial-data config/config-default-content) initial-data (sqlite-create-graph/build-db-initial-data (migrate-db-config config/config-default-content))
_ (db/transact! full-graph-name initial-data) _ (db/transact! full-graph-name initial-data)
_ (repo-config-handler/set-repo-config-state! full-graph-name config/config-default-content) _ (repo-config-handler/set-repo-config-state! full-graph-name config/config-default-content)
;; TODO: handle global graph ;; TODO: handle global graph