Function: org-roam-db-sync
org-roam-db-sync is an autoloaded, interactive and byte-compiled
function defined in org-roam-db.el.
Signature
(org-roam-db-sync &optional FORCE)
Documentation
Synchronize the cache state with the current Org files on-disk.
If FORCE, force a rebuild of the cache from scratch.
Key Bindings
Source Code
;; Defined in ~/.emacs.d/elpa/org-roam-20260224.1637/org-roam-db.el
;;;###autoload
(defun org-roam-db-sync (&optional force)
"Synchronize the cache state with the current Org files on-disk.
If FORCE, force a rebuild of the cache from scratch."
(interactive "P")
(org-roam-db--close) ;; Force a reconnect
(when force (delete-file org-roam-db-location))
(org-roam-db) ;; To initialize the database, no-op if already initialized
(require 'org-ref nil t)
(require 'oc nil t)
(let* ((gc-cons-threshold org-roam-db-gc-threshold)
(org-agenda-files nil)
(org-roam-files (org-roam-list-files))
(current-files (org-roam-db--get-current-files))
(modified-files nil))
(dolist (file org-roam-files)
(let ((contents-hash (org-roam-db--file-hash file)))
(unless (string= (gethash file current-files)
contents-hash)
(push file modified-files)))
(remhash file current-files))
(emacsql-with-transaction (org-roam-db)
(dolist-with-progress-reporter (file (hash-table-keys current-files))
"Clearing removed files..."
(org-roam-db-clear-file file))
(dolist-with-progress-reporter (file modified-files)
"Processing modified files..."
(condition-case err
(org-roam-db-update-file file)
(error
(org-roam-db-clear-file file)
(lwarn 'org-roam :error "Failed to process %s with error %s, skipping..."
file (error-message-string err))))))))