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

    Add: (h/clear-cache) Clear local cache for file or directory
---
 hyperdrive.el | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/hyperdrive.el b/hyperdrive.el
index 87aef7f4b7..71017e669a 100644
--- a/hyperdrive.el
+++ b/hyperdrive.el
@@ -181,6 +181,25 @@ Interactively, prompt for hyperdrive and action."
                     (propertize "safe" 'face 'success)
                   (propertize "unsafe" 'face 'error))))))
 
+(defun h/clear-cache (entry)
+  "Clear local cache for file or directory ENTRY.
+Only clears the cache for the file or directory at ENTRY's
+version; other versions of the file or directory are not cleared."
+  ;; TODO: Considering support an :all-versions key for clearing the cache for
+  ;; all versions of the file/directory.
+  (interactive (list (hyperdrive--context-entry)))
+  (let ((url (he/url entry)))
+    (h/api 'delete url
+      :headers '(("Cache-Control" . "no-store"))
+      :as 'response
+      :else (lambda (err)
+              (h/error "Unable to clear cache for `%s': %S" url err))
+      :then (lambda (response)
+              (h//fill entry (plz-response-headers response))
+              ;; TODO: When file sizes in hyperdrive-dir-mode are colorized
+              ;; based locally downloaded sizes, refresh ewoc entry here.
+              ))))
+
 ;;;###autoload
 (defun hyperdrive-purge (hyperdrive)
   "Purge all data corresponding to HYPERDRIVE."

Reply via email to