Browse Source

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).
Ihor Radchenko 3 years ago
parent
commit
849dd68b27
1 changed files with 5 additions and 1 deletions
  1. 5 1
      lisp/org-persist.el

+ 5 - 1
lisp/org-persist.el

@@ -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.