org-persist.el/org-persist--read-index: Handle reader errors

* lisp/org-persist.el (org-persist--read-index): Do not emit
unrecoverable error if index file is corrupted (i.e. empty).
This commit is contained in:
Ihor Radchenko 2021-10-20 20:33:55 +08:00
parent 7b9203f2ba
commit 849dd68b27
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 5 additions and 1 deletions

View File

@ -107,7 +107,11 @@ When BUFFER is nil, return plist for global VAR."
(when (file-exists-p (org-file-name-concat org-persist-directory org-persist-index-file))
(with-temp-buffer
(insert-file-contents (org-file-name-concat org-persist-directory org-persist-index-file))
(setq org-persist--index (read (current-buffer)))))))
(setq org-persist--index
(condition-case err
(read (current-buffer))
;; Recover gracefully if index file is corrupted.
(error nil)))))))
(cl-defun org-persist-register (var &optional buffer &key inherit)
"Register VAR in BUFFER to be persistent.