mirror of
https://github.com/logseq/logseq.git
synced 2026-06-01 19:01:22 +00:00
refactor: centralize default graphs dir spread across cli and electron
Having different definitions doesn't allow for configurability and can lead to bugs. Also addressed sqlite-cli having one-off definition
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
[frontend.worker.state :as worker-state]
|
||||
[lambdaisland.glogi :as log]
|
||||
[logseq.cli.style :as style]
|
||||
[logseq.common.config :as common-config]
|
||||
[logseq.cli.data-dir :as data-dir]
|
||||
[logseq.db :as ldb]
|
||||
[promesa.core :as p]))
|
||||
@@ -282,7 +283,7 @@
|
||||
(defn- show-help!
|
||||
[]
|
||||
(println (str (style/bold "db-worker-node") " " (style/bold "options") ":"))
|
||||
(println (str " " (style/bold "--data-dir") " <path> (default ~/logseq/graphs)"))
|
||||
(println (str " " (style/bold "--data-dir") " <path> (default " common-config/default-graphs-dir ")"))
|
||||
(println (str " " (style/bold "--repo") " <name> (required)"))
|
||||
(println (str " " (style/bold "--create-empty-db") " (start with empty initial datoms)"))
|
||||
(println (str " " (style/bold "--log-level") " <level> (default info)"))
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
["os" :as os]
|
||||
["path" :as node-path]
|
||||
[clojure.string :as string]
|
||||
[frontend.worker.graph-dir :as graph-dir]
|
||||
[frontend.worker-common.util :as worker-util]
|
||||
[frontend.worker.graph-dir :as graph-dir]
|
||||
[lambdaisland.glogi :as log]
|
||||
[logseq.common.config :as common-config]
|
||||
[logseq.common.graph :as common-graph]
|
||||
[promesa.core :as p]))
|
||||
|
||||
(defn- expand-home
|
||||
@@ -18,7 +19,7 @@
|
||||
|
||||
(defn resolve-data-dir
|
||||
[data-dir]
|
||||
(expand-home (or data-dir "~/logseq/graphs")))
|
||||
(expand-home (or data-dir common-graph/get-default-graphs-dir)))
|
||||
|
||||
(defn repo->graph-dir-key
|
||||
[repo]
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
[goog.object :as gobj]
|
||||
[lambdaisland.glogi :as log]
|
||||
[logseq.common.config :as common-config]
|
||||
[logseq.common.graph :as common-graph]
|
||||
[promesa.core :as p]))
|
||||
|
||||
(defn- resolve-database-sync-ctor
|
||||
@@ -299,7 +300,7 @@
|
||||
|
||||
(defn node-platform
|
||||
[{:keys [data-dir event-fn write-guard-fn owner-source]}]
|
||||
(let [data-dir (expand-home (or data-dir "~/logseq/graphs"))
|
||||
(let [data-dir (expand-home (or data-dir (common-graph/get-default-graphs-dir)))
|
||||
owner-source (db-lock/normalize-owner-source owner-source)
|
||||
kv (kv-store data-dir)]
|
||||
(p/do!
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
:alias :c}
|
||||
:graph {:desc "Graph name"
|
||||
:alias :g}
|
||||
:data-dir {:desc "Path to db-worker data dir (default ~/logseq/graphs)"}
|
||||
:data-dir {:desc (str "Path to db-worker data dir (default " common-config/default-graphs-dir ")")}
|
||||
:timeout-ms {:desc "Request timeout in ms (default 10000)"
|
||||
:coerce :long}
|
||||
:output {:desc "Output format (human, json, edn). Default: human"
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
[goog.object :as gobj]
|
||||
["fs" :as fs]
|
||||
["os" :as os]
|
||||
["path" :as node-path]))
|
||||
["path" :as node-path]
|
||||
[logseq.common.graph :as common-graph]))
|
||||
|
||||
(defn- parse-int
|
||||
[value]
|
||||
@@ -98,7 +99,7 @@
|
||||
:login-timeout-ms 300000
|
||||
:logout-timeout-ms 120000
|
||||
:output-format nil
|
||||
:data-dir "~/logseq/graphs"
|
||||
:data-dir (common-graph/get-default-graphs-dir)
|
||||
:config-path (default-config-path)}
|
||||
env (env-config)
|
||||
config-path (or (:config-path opts)
|
||||
|
||||
@@ -1,21 +1,12 @@
|
||||
(ns logseq.cli.data-dir
|
||||
"Data-dir validation and normalization for the CLI and db-worker-node."
|
||||
(:require ["fs" :as fs]
|
||||
["os" :as os]
|
||||
["path" :as node-path]
|
||||
[clojure.string :as string]))
|
||||
|
||||
(def ^:private default-data-dir "~/logseq/graphs")
|
||||
|
||||
(defn- expand-home
|
||||
[path]
|
||||
(if (and (seq path) (string/starts-with? path "~"))
|
||||
(node-path/join (.homedir os) (subs path 1))
|
||||
path))
|
||||
[logseq.common.graph :as common-graph]))
|
||||
|
||||
(defn normalize-data-dir
|
||||
[path]
|
||||
(node-path/resolve (expand-home (or path default-data-dir))))
|
||||
(node-path/resolve (common-graph/expand-home (or path (common-graph/get-default-graphs-dir)))))
|
||||
|
||||
(defn ensure-data-dir!
|
||||
[path]
|
||||
|
||||
@@ -1,24 +1,18 @@
|
||||
(ns logseq.cli.server
|
||||
"db-worker-node lifecycle orchestration for logseq."
|
||||
(:require ["fs" :as fs]
|
||||
["os" :as os]
|
||||
["path" :as node-path]
|
||||
[clojure.string :as string]
|
||||
[frontend.worker.db-worker-node-lock :as db-lock]
|
||||
[logseq.common.config :as common-config]
|
||||
[logseq.db-worker.daemon :as daemon]
|
||||
[lambdaisland.glogi :as log]
|
||||
[logseq.common.config :as common-config]
|
||||
[logseq.common.graph :as common-graph]
|
||||
[logseq.db-worker.daemon :as daemon]
|
||||
[promesa.core :as p]))
|
||||
|
||||
(defn- expand-home
|
||||
[path]
|
||||
(if (string/starts-with? path "~")
|
||||
(node-path/join (.homedir os) (subs path 1))
|
||||
path))
|
||||
|
||||
(defn resolve-data-dir
|
||||
[config]
|
||||
(expand-home (or (:data-dir config) "~/logseq/graphs")))
|
||||
(common-graph/expand-home (or (:data-dir config) (common-graph/get-default-graphs-dir))))
|
||||
|
||||
(defn- repo-dir
|
||||
[data-dir repo]
|
||||
|
||||
Reference in New Issue
Block a user