(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:
Jürgen Hötzel
2020-02-22 09:56:45 +01:00
committed by GitHub
parent 43ff60fec7
commit a2a858a0fe

View File

@@ -382,8 +382,9 @@ If PREFIX, downcase the title before insertion."
(defun org-roam--build-cache-async ()
"Builds the caches asychronously."
(interactive)
(unless org-roam--ongoing-async-build
(setq org-roam--ongoing-async-build t)
(unless (and (processp org-roam--ongoing-async-build)
(not (async-ready org-roam--ongoing-async-build)))
(setq org-roam--ongoing-async-build
(async-start
`(lambda ()
(setq load-path ',load-path)
@@ -398,10 +399,9 @@ If PREFIX, downcase the title before insertion."
org-roam-forward-links-cache (plist-get cache :forward)
org-roam-backward-links-cache (plist-get cache :backward)
org-roam-titles-cache (plist-get cache :titles)
org-roam-cache-initialized t
org-roam--ongoing-async-build nil)) ;; Remove lock
org-roam-cache-initialized t)
(unless org-roam-mute-cache-build
(message "Org-roam cache built!"))))))
(message "Org-roam cache built!"))))))))
(defun org-roam--clear-cache ()
"Clears all entries in the caches."