Karthik Chikmagalur <karthikchikmaga...@gmail.com> writes:

>> My guess is 7999433067 or 2a620113c1, but need to confirm.
>
> Yes it's one of those two, I'm not sure which of the two it is as I
> haven't had the time to reset the branch and test each one.

What if you try the attached diff?

diff --git a/lisp/org-persist.el b/lisp/org-persist.el
index a639699d93..6e8bf89120 100644
--- a/lisp/org-persist.el
+++ b/lisp/org-persist.el
@@ -452,6 +452,12 @@ (defun org-persist--read-elisp-file (&optional buffer-or-file)
                  buffer-or-file (error-message-string err)))
          nil)))))
 
+(defvar org-persist--write-inhibit-writing-index nil
+  "When non-nil, `org-persist--write-elisp-file' never writes index.
+This should only be let-bound when performing batch writes to cache.
+The code is then responsible to call `org-persist--save-index'
+manually to avoid desync.")
+
 ;; FIXME: `pp' is very slow when writing even moderately large datasets
 ;; We should probably drop it or find some fast formatter.
 (defun org-persist--write-elisp-file
@@ -492,7 +498,9 @@ (defun org-persist--write-elisp-file
     ;; date. This prevents situation when two Emacs sessions are writing
     ;; different data under the same cache key, but do not update the
     ;; index metadata about the cache data written (e.g. hash).
-    (when (or inhibit-writing-index (org-persist--save-index))
+    (when (or org-persist--write-inhibit-writing-index
+              inhibit-writing-index
+              (org-persist--save-index))
       (unless (file-exists-p (file-name-directory file))
         (make-directory (file-name-directory file) t))
       ;; Do not write to FILE directly.  Another Emacs instance may be
@@ -1190,7 +1198,9 @@ (defun org-persist-write-all (&optional associated)
                  (org-directory-empty-p org-persist-directory))
         (delete-directory org-persist-directory))
     ;; Write the data.
-    (let (all-containers)
+    (let (all-containers
+          (org-persist--write-inhibit-writing-index t))
+      (org-persist--save-index)
       (dolist (collection org-persist--index)
         (if associated
             (when collection
-- 
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

Reply via email to