From 0e6b93a253548a1874c64f97248ba540907ad4c9 Mon Sep 17 00:00:00 2001 From: Jethro Kuan Date: Sat, 28 Aug 2021 13:42:30 +0800 Subject: [PATCH] (fix)db: prevent invalid refs from crashing db update (#1816) Previously when ROAM_REFS is non-empty, but the refs are invalid, this will cause an empty SQL expression and crash the db caching. This fixes that scenario. --- CHANGELOG.md | 1 + org-roam-db.el | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 114de4c..63b205a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - [#1798](https://github.com/org-roam/org-roam/pull/1798) org-roam-node-at-point: do not skip invisible headings - [#1807](https://github.com/org-roam/org-roam/pull/1807) capture: always trigger `:if-new` template for existing nodes - [#1813](https://github.com/org-roam/org-roam/pull/1813) db: prevent empty ROAM_ALIASES from crashing db updates +- [#1816](https://github.com/org-roam/org-roam/pull/1816) db: prevent invalid ROAM_REFS from crashing db updates ## 2.1.0 ### Added diff --git a/org-roam-db.el b/org-roam-db.el index 68df506..fc96376 100644 --- a/org-roam-db.el +++ b/org-roam-db.el @@ -418,9 +418,10 @@ If UPDATE-P is non-nil, first remove the file in the database." (push (vector node-id (match-string 2 ref) (match-string 1 ref)) rows)) (lwarn '(org-roam) :warning "%s:%s\tInvalid ref %s, skipping..." (buffer-file-name) (point) ref)))) - (org-roam-db-query [:insert :into refs - :values $v1] - rows)))) + (when rows + (org-roam-db-query [:insert :into refs + :values $v1] + rows))))) (defun org-roam-db-insert-link (link) "Insert link data for LINK at current point into the Org-roam cache."