mirror of
https://github.com/logseq/logseq.git
synced 2026-05-16 08:52:20 +00:00
056-graph-name-dir-encoding-alignment.md
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
["path" :as node-path]
|
||||
[electron.backup-file :as backup-file]
|
||||
[logseq.cli.common.graph :as cli-common-graph]
|
||||
[logseq.common.graph-dir :as graph-dir]
|
||||
[logseq.db.common.sqlite :as common-sqlite]))
|
||||
|
||||
(defn ensure-graphs-dir!
|
||||
|
||||
@@ -4,20 +4,20 @@
|
||||
["path" :as node-path]
|
||||
[logseq.common.config :as common-config]
|
||||
[logseq.common.graph :as common-graph]
|
||||
[logseq.db.common.sqlite :as common-sqlite]))
|
||||
[logseq.common.graph-dir :as graph-dir]))
|
||||
|
||||
(defn unlink-graph!
|
||||
"Unlinks the given repo by moving it to the 'Unlinked graphs' dir.
|
||||
Returns path of unlinked dir if move is successful or nil if not"
|
||||
[repo]
|
||||
(let [db-name (common-sqlite/sanitize-db-name repo)
|
||||
(let [graph-dir-name (graph-dir/repo->encoded-graph-dir-name repo)
|
||||
graphs-dir (common-graph/expand-home (common-graph/get-default-graphs-dir))
|
||||
path (node-path/join graphs-dir db-name)
|
||||
path (node-path/join graphs-dir graph-dir-name)
|
||||
unlinked (node-path/join graphs-dir common-config/unlinked-graphs-dir)
|
||||
new-path (node-path/join unlinked db-name)
|
||||
new-path (node-path/join unlinked graph-dir-name)
|
||||
new-path-exists? (fs/existsSync new-path)
|
||||
new-path' (if new-path-exists?
|
||||
(node-path/join unlinked (str db-name "-" (random-uuid)))
|
||||
(node-path/join unlinked (str graph-dir-name "-" (random-uuid)))
|
||||
new-path)]
|
||||
(when (fs/existsSync path)
|
||||
(fs/ensureDirSync unlinked)
|
||||
|
||||
@@ -9,10 +9,11 @@
|
||||
|
||||
(deftest unlink-graph-moves-to-unlinked-dir
|
||||
(let [graphs-dir (node-helper/create-tmp-dir "unlink-graph")
|
||||
graph-name "test-graph"
|
||||
graph-name "foo/bar"
|
||||
repo (str common-config/db-version-prefix graph-name)
|
||||
graph-path (node-path/join graphs-dir graph-name)
|
||||
unlinked-path (node-path/join graphs-dir common-config/unlinked-graphs-dir graph-name)]
|
||||
encoded-graph-dir "foo~2Fbar"
|
||||
graph-path (node-path/join graphs-dir encoded-graph-dir)
|
||||
unlinked-path (node-path/join graphs-dir common-config/unlinked-graphs-dir encoded-graph-dir)]
|
||||
(fs/mkdirSync graph-path #js {:recursive true})
|
||||
(fs/writeFileSync (node-path/join graph-path "db.sqlite") "test-data")
|
||||
(with-redefs [common-graph/get-default-graphs-dir (fn [] graphs-dir)]
|
||||
|
||||
Reference in New Issue
Block a user