mirror of
https://github.com/org-roam/org-roam
synced 2025-08-29 14:33:29 -05:00
catch duplicate IDs during DB insertion
This commit is contained in:
@@ -281,6 +281,8 @@ If UPDATE-P is non-nil, first remove the file in the database."
|
|||||||
(aliases (org-entry-get (point) "ROAM_ALIASES"))
|
(aliases (org-entry-get (point) "ROAM_ALIASES"))
|
||||||
(tags org-file-tags)
|
(tags org-file-tags)
|
||||||
(refs (org-entry-get (point) "ROAM_REFS")))
|
(refs (org-entry-get (point) "ROAM_REFS")))
|
||||||
|
(condition-case err
|
||||||
|
(progn
|
||||||
(org-roam-db-query
|
(org-roam-db-query
|
||||||
[:insert :into nodes
|
[:insert :into nodes
|
||||||
:values $v1]
|
:values $v1]
|
||||||
@@ -306,14 +308,18 @@ If UPDATE-P is non-nil, first remove the file in the database."
|
|||||||
(dolist (ref refs)
|
(dolist (ref refs)
|
||||||
(if (string-match org-link-plain-re ref)
|
(if (string-match org-link-plain-re ref)
|
||||||
(progn
|
(progn
|
||||||
(push (vector file id (match-string 2 ref) (match-string 1 ref)) rows))
|
(push (vector file id (match-string 2 ref)
|
||||||
|
(match-string 1 ref)) rows))
|
||||||
(lwarn '(org-roam) :warning
|
(lwarn '(org-roam) :warning
|
||||||
"%s:%s\tInvalid ref %s, skipping..." (buffer-file-name) (point) ref)))
|
"%s:%s\tInvalid ref %s, skipping..."
|
||||||
|
(buffer-file-name) (point) ref)))
|
||||||
(when rows
|
(when rows
|
||||||
(org-roam-db-query
|
(org-roam-db-query
|
||||||
[:insert :into refs
|
[:insert :into refs
|
||||||
:values $v1]
|
:values $v1]
|
||||||
rows)))))))))
|
rows)))))
|
||||||
|
(t
|
||||||
|
(lwarn '(org-roam) :error "Duplicate ID %s, skipping..." id))))))))
|
||||||
|
|
||||||
(defun org-roam-db-insert-node-data ()
|
(defun org-roam-db-insert-node-data ()
|
||||||
"Insert node data for headline at point into the Org-roam cache."
|
"Insert node data for headline at point into the Org-roam cache."
|
||||||
@@ -327,11 +333,15 @@ If UPDATE-P is non-nil, first remove the file in the database."
|
|||||||
(scheduled (org-roam-db-get-scheduled-time))
|
(scheduled (org-roam-db-get-scheduled-time))
|
||||||
(deadline (org-roam-db-get-deadline-time))
|
(deadline (org-roam-db-get-deadline-time))
|
||||||
(title (nth 4 heading-components)))
|
(title (nth 4 heading-components)))
|
||||||
|
(condition-case err
|
||||||
(org-roam-db-query
|
(org-roam-db-query
|
||||||
[:insert :into nodes
|
[:insert :into nodes
|
||||||
:values $v1]
|
:values $v1]
|
||||||
(vector id file level pos todo priority
|
(vector id file level pos todo priority
|
||||||
scheduled deadline title)))))
|
scheduled deadline title))
|
||||||
|
(t
|
||||||
|
(lwarn '(org-roam) :error
|
||||||
|
"Duplicate ID %s, skipping..." id))))))
|
||||||
|
|
||||||
(defun org-roam-db-insert-aliases ()
|
(defun org-roam-db-insert-aliases ()
|
||||||
"Insert aliases for node at point into Org-roam cache."
|
"Insert aliases for node at point into Org-roam cache."
|
||||||
|
Reference in New Issue
Block a user