mirror of
https://github.com/org-roam/org-roam
synced 2025-08-27 14:23:32 -05:00
(bugfix): Check future status to prevent multiple async tasks (#160)
Prevents that the `org-roam--build-cache-async` process is blocked forever if an async error occurs. Refs #149, #151
This commit is contained in:
40
org-roam.el
40
org-roam.el
@@ -382,26 +382,26 @@ If PREFIX, downcase the title before insertion."
|
|||||||
(defun org-roam--build-cache-async ()
|
(defun org-roam--build-cache-async ()
|
||||||
"Builds the caches asychronously."
|
"Builds the caches asychronously."
|
||||||
(interactive)
|
(interactive)
|
||||||
(unless org-roam--ongoing-async-build
|
(unless (and (processp org-roam--ongoing-async-build)
|
||||||
(setq org-roam--ongoing-async-build t)
|
(not (async-ready org-roam--ongoing-async-build)))
|
||||||
(async-start
|
(setq org-roam--ongoing-async-build
|
||||||
`(lambda ()
|
(async-start
|
||||||
(setq load-path ',load-path)
|
`(lambda ()
|
||||||
(package-initialize)
|
(setq load-path ',load-path)
|
||||||
(require 'org-roam-utils)
|
(package-initialize)
|
||||||
,(async-inject-variables "org-roam-directory")
|
(require 'org-roam-utils)
|
||||||
(cons org-roam-directory (org-roam--build-cache org-roam-directory)))
|
,(async-inject-variables "org-roam-directory")
|
||||||
(lambda (pair)
|
(cons org-roam-directory (org-roam--build-cache org-roam-directory)))
|
||||||
(let ((directory (car pair))
|
(lambda (pair)
|
||||||
(cache (cdr pair)))
|
(let ((directory (car pair))
|
||||||
(setq org-roam-directory directory ;; ensure dir matches cache
|
(cache (cdr pair)))
|
||||||
org-roam-forward-links-cache (plist-get cache :forward)
|
(setq org-roam-directory directory ;; ensure dir matches cache
|
||||||
org-roam-backward-links-cache (plist-get cache :backward)
|
org-roam-forward-links-cache (plist-get cache :forward)
|
||||||
org-roam-titles-cache (plist-get cache :titles)
|
org-roam-backward-links-cache (plist-get cache :backward)
|
||||||
org-roam-cache-initialized t
|
org-roam-titles-cache (plist-get cache :titles)
|
||||||
org-roam--ongoing-async-build nil)) ;; Remove lock
|
org-roam-cache-initialized t)
|
||||||
(unless org-roam-mute-cache-build
|
(unless org-roam-mute-cache-build
|
||||||
(message "Org-roam cache built!"))))))
|
(message "Org-roam cache built!"))))))))
|
||||||
|
|
||||||
(defun org-roam--clear-cache ()
|
(defun org-roam--clear-cache ()
|
||||||
"Clears all entries in the caches."
|
"Clears all entries in the caches."
|
||||||
|
Reference in New Issue
Block a user