branch: elpa/hyperdrive
commit d4c069ca0e02a19d8f73e3d51ddb7a9784b5dd35
Author: Joseph Turner <jos...@ushin.org>
Commit: Joseph Turner <jos...@ushin.org>

    Change: (he//invalidate) Only invalidate select entry slots
    
    Previously, EWOC entry data was replaced entirely with the entry which
    was available in the function which called he//invalidate, usually
    he//api-then.  However, when h/forget-file was called, the entry it
    passed to he/api and he//api-then lacked the ETC slot RANGE-END and
    EXISTSP values, and so when the history buffer ewoc node entry was
    invalidated, the ewoc printer signaled an error.
    
    Now, ewoc node entries are reused, and only select slots are updated.
    This ensures that RANGE-END and EXISTSP values remain.
    
    If server responses always returned all metadata necessary to render
    each entry, this change might not be necessary.  However range-end
    data requires traversing backward through the version history and
    doing this for each request may pose a performance issue.
    
    Also, there are other metadata which are buffer-specific and should
    not be erased when invalidating an ewoc node entry, such as the ETC
    slot DISPLAY-NAME key.  By only refreshing specific slots, we are
    likely to prevent confusing bugs in the future if other
    buffer-specific data gets stored in buffer-local hyperdrive entries.
---
 hyperdrive-ewoc.el | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/hyperdrive-ewoc.el b/hyperdrive-ewoc.el
index b067a0c0bc..87fc4bc14d 100644
--- a/hyperdrive-ewoc.el
+++ b/hyperdrive-ewoc.el
@@ -52,14 +52,23 @@ last node."
            do (setf node (ewoc-prev ewoc node))))
 
 (defun he//invalidate (entry)
-  "Invalidate ENTRY's ewoc node in directory and history buffers."
+  "Invalidate ENTRY's ewoc node in directory and history buffers.
+Invalidated ewoc node entries will have these slots updated:
+
+- ETC
+  + BLOCK-LENGTH-DOWNLOADED
+
+All other slots in each ewoc node entry data will be reused."
   (when-let* ((dir-buffer (hyperdrive--find-buffer-visiting
                            (hyperdrive-parent entry)))
               (dir-ewoc (buffer-local-value 'h/ewoc dir-buffer))
               (dir-node (and dir-ewoc
                              (h/ewoc-find-node dir-ewoc entry
-                               :predicate #'he/equal-p))))
-    (ewoc-set-data dir-node entry)
+                               :predicate #'he/equal-p)))
+              (dir-ewoc-entry (ewoc-data dir-node)))
+    (setf (map-elt (he/etc dir-ewoc-entry) 'block-length-downloaded)
+          (map-elt (he/etc entry) 'block-length-downloaded))
+    (ewoc-set-data dir-node dir-ewoc-entry)
     ;; NOTE: Ensure that the buffer's window is selected,
     ;; if it has one.  (Workaround a possible bug in EWOC.)
     (if-let ((buffer-window (get-buffer-window dir-buffer)))
@@ -71,8 +80,11 @@ last node."
               (history-ewoc (buffer-local-value 'h/ewoc history-buffer))
               (history-node (and history-ewoc
                                  (h/ewoc-find-node history-ewoc entry
-                                   :predicate #'he/within-version-range))))
-    (ewoc-set-data history-node entry)
+                                   :predicate #'he/within-version-range)))
+              (history-ewoc-entry (ewoc-data history-node)))
+    (setf (map-elt (he/etc history-ewoc-entry) 'block-length-downloaded)
+          (map-elt (he/etc entry) 'block-length-downloaded))
+    (ewoc-set-data history-node history-ewoc-entry)
     ;; NOTE: Ensure that the buffer's window is selected,
     ;; if it has one.  (Workaround a possible bug in EWOC.)
     (if-let ((buffer-window (get-buffer-window history-buffer)))

Reply via email to