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

    Add: (he//invalidate) Move into separate function
---
 hyperdrive-ewoc.el | 18 ++++++++++++++++++
 hyperdrive.el      | 15 +--------------
 2 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/hyperdrive-ewoc.el b/hyperdrive-ewoc.el
index 10cc500663..d58e18e5ee 100644
--- a/hyperdrive-ewoc.el
+++ b/hyperdrive-ewoc.el
@@ -51,6 +51,24 @@ last node."
            return node
            do (setf node (ewoc-prev ewoc node))))
 
+(defun he//invalidate (entry)
+  "Invalidate the ewoc node for ENTRY in directory buffers."
+  (when-let* ((buffer (hyperdrive--find-buffer-visiting
+                       (hyperdrive-parent entry)))
+              (ewoc (buffer-local-value 'h/ewoc buffer))
+              (node (and ewoc
+                         (h/ewoc-find-node ewoc entry
+                           :predicate #'he/equal-p))))
+    (when node
+      (ewoc-set-data node 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 (ewoc-buffer ewoc))))
+          (with-selected-window buffer-window
+            (with-silent-modifications (ewoc-invalidate ewoc node)))
+        (with-current-buffer (ewoc-buffer ewoc)
+          (with-silent-modifications (ewoc-invalidate ewoc node)))))))
+
 ;;;; Mode
 
 (defvar-keymap h/ewoc-mode-map
diff --git a/hyperdrive.el b/hyperdrive.el
index a0cb2590d3..8c28db6e60 100644
--- a/hyperdrive.el
+++ b/hyperdrive.el
@@ -203,20 +203,7 @@ modified; file blobs may be recoverable from other peers."
               (h/error "Unable to clear cache for `%s': %S" (he/url entry) 
err))
       :then (lambda (response)
               (he//fill entry (plz-response-headers response))
-              ;; Update the face showing the file size in any directory buffer.
-              (when-let* ((buffer (hyperdrive--find-buffer-visiting
-                                   (hyperdrive-parent entry)))
-                          (ewoc (buffer-local-value 'h/ewoc buffer))
-                          (node (h/ewoc-find-node ewoc entry
-                                  :predicate #'he/equal-p)))
-                (ewoc-set-data node 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 (ewoc-buffer 
ewoc))))
-                    (with-selected-window buffer-window
-                      (with-silent-modifications (ewoc-invalidate ewoc node)))
-                  (with-current-buffer (ewoc-buffer ewoc)
-                    (with-silent-modifications (ewoc-invalidate ewoc 
node)))))))))
+              (he//invalidate entry)))))
 
 ;;;###autoload
 (defun hyperdrive-purge (hyperdrive)

Reply via email to