mirror of
https://github.com/logseq/logseq.git
synced 2026-06-01 19:01:22 +00:00
refactor(worker): extract graph dir key helper
This commit is contained in:
@@ -11,11 +11,11 @@
|
||||
[frontend.common.graph-view :as graph-view]
|
||||
[frontend.common.missionary :as c.m]
|
||||
[frontend.common.thread-api :as thread-api :refer [def-thread-api]]
|
||||
[frontend.worker.graph-dir :as graph-dir]
|
||||
[frontend.worker.platform :as platform]
|
||||
[frontend.worker-common.util :as worker-util]
|
||||
[frontend.worker.db-listener :as db-listener]
|
||||
[frontend.worker.db-metadata :as worker-db-metadata]
|
||||
[frontend.worker.db-worker-node-lock :as db-lock]
|
||||
[frontend.worker.db.fix :as db-fix]
|
||||
[frontend.worker.db.migrate :as db-migrate]
|
||||
[frontend.worker.db.validate :as worker-db-validate]
|
||||
@@ -73,7 +73,7 @@
|
||||
(defn- storage-pool-name
|
||||
[graph]
|
||||
(if (node-runtime?)
|
||||
(db-lock/repo->graph-dir-key graph)
|
||||
(graph-dir/repo->graph-dir-key graph)
|
||||
(worker-util/get-pool-name graph)))
|
||||
|
||||
(defn- get-storage-pool
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
["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]
|
||||
[lambdaisland.glogi :as log]
|
||||
[logseq.common.config :as common-config]
|
||||
@@ -21,10 +22,7 @@
|
||||
|
||||
(defn repo->graph-dir-key
|
||||
[repo]
|
||||
(when (seq repo)
|
||||
(if (string/starts-with? repo common-config/db-version-prefix)
|
||||
(subs repo (count common-config/db-version-prefix))
|
||||
repo)))
|
||||
(graph-dir/repo->graph-dir-key repo))
|
||||
|
||||
(defn canonical-graph-dir-key?
|
||||
[graph-dir-key]
|
||||
|
||||
11
src/main/frontend/worker/graph_dir.cljs
Normal file
11
src/main/frontend/worker/graph_dir.cljs
Normal file
@@ -0,0 +1,11 @@
|
||||
(ns frontend.worker.graph-dir
|
||||
"Platform-agnostic graph directory naming helpers."
|
||||
(:require [clojure.string :as string]
|
||||
[logseq.common.config :as common-config]))
|
||||
|
||||
(defn repo->graph-dir-key
|
||||
[repo]
|
||||
(when (seq repo)
|
||||
(if (string/starts-with? repo common-config/db-version-prefix)
|
||||
(subs repo (count common-config/db-version-prefix))
|
||||
repo)))
|
||||
11
src/test/frontend/worker/graph_dir_test.cljs
Normal file
11
src/test/frontend/worker/graph_dir_test.cljs
Normal file
@@ -0,0 +1,11 @@
|
||||
(ns frontend.worker.graph-dir-test
|
||||
(:require [cljs.test :refer [deftest is testing]]
|
||||
[frontend.worker.graph-dir :as graph-dir]))
|
||||
|
||||
(deftest repo->graph-dir-key-strips-db-prefix
|
||||
(testing "db-prefixed repo is mapped to prefix-free graph dir key"
|
||||
(is (= "demo" (graph-dir/repo->graph-dir-key "logseq_db_demo")))))
|
||||
|
||||
(deftest repo->graph-dir-key-keeps-prefix-free-name
|
||||
(testing "prefix-free repo remains unchanged"
|
||||
(is (= "demo" (graph-dir/repo->graph-dir-key "demo")))))
|
||||
Reference in New Issue
Block a user