mirror of
https://github.com/org-roam/org-roam
synced 2025-08-01 12:17:21 -05:00
(internal): move org-roam.db default location (#1164)
Move the default location of `org-roam.db` to the user's Emacs directory. This is a more sensible default: those who sync their Org files would not have the database synced over as well.
This commit is contained in:
@ -8,6 +8,7 @@ Org-roam also now does not resolve symlinks. This significantly speeds up cache
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- [#1164](https://github.com/org-roam/org-roam/pull/1164) Org-roam now stores the database in the user's Emacs directory by default
|
||||
- [#910](https://github.com/org-roam/org-roam/pull/910) Deprecate `company-org-roam`, using `completion-at-point` instead. To use this with company, add the `company-capf` backend instead.
|
||||
- [#1109](https://github.com/org-roam/org-roam/pull/1109) Org-roam now does not resolve symlinks.
|
||||
|
||||
|
@ -41,8 +41,6 @@
|
||||
"org-roam 1.0.0")
|
||||
(define-obsolete-function-alias 'org-roam-sql 'org-roam-db-query
|
||||
"org-roam 1.0.0")
|
||||
(define-obsolete-function-alias 'org-roam--get-db 'org-roam-db--get
|
||||
"org-roam 1.0.0")
|
||||
(define-obsolete-function-alias 'org-roam--db-clear 'org-roam-db--clear
|
||||
"org-roam 1.0.0")
|
||||
(define-obsolete-function-alias 'org-roam-show-graph 'org-roam-graph-show
|
||||
|
@ -55,7 +55,7 @@
|
||||
(declare-function org-roam-buffer--update-maybe "org-roam-buffer")
|
||||
|
||||
;;;; Options
|
||||
(defcustom org-roam-db-location nil
|
||||
(defcustom org-roam-db-location (expand-file-name "org-roam.db" user-emacs-directory)
|
||||
"The full path to file where the Org-roam database is stored.
|
||||
If this is non-nil, the Org-roam sqlite database is saved here.
|
||||
|
||||
@ -85,10 +85,6 @@ value like `most-positive-fixnum'."
|
||||
"Database connection to Org-roam database.")
|
||||
|
||||
;;;; Core Functions
|
||||
(defun org-roam-db--get ()
|
||||
"Return the sqlite db file."
|
||||
(or org-roam-db-location
|
||||
(expand-file-name "org-roam.db" org-roam-directory)))
|
||||
|
||||
(defun org-roam-db--get-connection ()
|
||||
"Return the database connection, if any."
|
||||
@ -101,10 +97,9 @@ Initializes and stores the database, and the database connection.
|
||||
Performs a database upgrade when required."
|
||||
(unless (and (org-roam-db--get-connection)
|
||||
(emacsql-live-p (org-roam-db--get-connection)))
|
||||
(let* ((db-file (org-roam-db--get))
|
||||
(init-db (not (file-exists-p db-file))))
|
||||
(make-directory (file-name-directory db-file) t)
|
||||
(let ((conn (emacsql-sqlite3 db-file)))
|
||||
(let ((init-db (not (file-exists-p org-roam-db-location))))
|
||||
(make-directory (file-name-directory org-roam-db-location) t)
|
||||
(let ((conn (emacsql-sqlite3 org-roam-db-location)))
|
||||
(set-process-query-on-exit-flag (emacsql-process conn) nil)
|
||||
(puthash (expand-file-name org-roam-directory)
|
||||
conn
|
||||
@ -200,7 +195,7 @@ the current `org-roam-directory'."
|
||||
;;;;; Initialization
|
||||
(defun org-roam-db--initialized-p ()
|
||||
"Whether the Org-roam cache has been initialized."
|
||||
(and (file-exists-p (org-roam-db--get))
|
||||
(and (file-exists-p org-roam-db-location)
|
||||
(> (caar (org-roam-db-query [:select (funcall count) :from titles]))
|
||||
0)))
|
||||
|
||||
@ -213,7 +208,7 @@ the current `org-roam-directory'."
|
||||
(defun org-roam-db-clear ()
|
||||
"Clears all entries in the Org-roam cache."
|
||||
(interactive)
|
||||
(when (file-exists-p (org-roam-db--get))
|
||||
(when (file-exists-p org-roam-db-location)
|
||||
(dolist (table (mapcar #'car org-roam-db--table-schemata))
|
||||
(org-roam-db-query `[:delete :from ,table]))))
|
||||
|
||||
@ -477,7 +472,7 @@ If the file exists, update the cache with information."
|
||||
"Build the cache for `org-roam-directory'.
|
||||
If FORCE, force a rebuild of the cache from scratch."
|
||||
(interactive "P")
|
||||
(when force (delete-file (org-roam-db--get)))
|
||||
(when force (delete-file org-roam-db-location))
|
||||
(org-roam-db--close) ;; Force a reconnect
|
||||
(org-roam-db) ;; To initialize the database, no-op if already initialized
|
||||
(let* ((gc-cons-threshold org-roam-db-gc-threshold)
|
||||
|
@ -49,7 +49,7 @@
|
||||
|
||||
(defun test-org-roam--teardown ()
|
||||
(org-roam-mode -1)
|
||||
(delete-file (org-roam-db--get))
|
||||
(delete-file org-roam-db-location)
|
||||
(org-roam-db--close))
|
||||
|
||||
(describe "org-roam--str-to-list"
|
||||
|
Reference in New Issue
Block a user