branch: externals/org
commit 4ec1087f6c5e081266e165b89c17ee7fbbf26e7c
Author: Ihor Radchenko <yanta...@posteo.net>
Commit: Ihor Radchenko <yanta...@posteo.net>

    org-persist: Fix adding duplicate index entries when merging with disk index
    
    * lisp/org-persist.el (org-persist--merge-index): Do not use `equal'
    to compare index entries.  Instead try searching index properly,
    accounting for :associated being file+hash.  We should consider the
    same file but different hash as the same index entry and only keep a
    single index instance.  Otherwise, the index will keep accumulating
    entries.
    (org-persist--merge-index-with-disk): Make sure that we update
    `org-persist--index-hash'.
---
 lisp/org-persist.el | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lisp/org-persist.el b/lisp/org-persist.el
index ae75ab7afc..6579a8e47c 100644
--- a/lisp/org-persist.el
+++ b/lisp/org-persist.el
@@ -959,14 +959,17 @@ Otherwise, return t."
     (when disk-index
       (setq org-persist--index combined-index
             org-persist--index-age
-            (file-attribute-modification-time (file-attributes index-file))))))
+            (file-attribute-modification-time (file-attributes index-file)))
+      ;; Store newly added entries in the index hash.
+      (mapc (lambda (collection) (org-persist--add-to-index collection 'hash))
+            org-persist--index))))
 
 (defun org-persist--merge-index (base other)
   "Attempt to merge new index items in OTHER into BASE.
 Items with different details are considered too difficult, and skipped."
   (if other
       (if (not base) other
-        (let ((new (cl-set-difference other base :test #'equal))
+        (let ((new (cl-set-difference other base :test 
#'org-persist--find-index))
               (base-files (mapcar (lambda (s) (plist-get s :persist-file)) 
base))
               (combined (reverse base)))
           (dolist (item (nreverse new))

Reply via email to