[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/hyperdrive 2ce5f9c3a9 01/13: Change: (hyperdrive-mirror.el
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/hyperdrive 2ce5f9c3a9 01/13: Change: (hyperdrive-mirror.el) Compare file modification times |
Date: |
Fri, 8 Sep 2023 19:00:08 -0400 (EDT) |
branch: elpa/hyperdrive
commit 2ce5f9c3a9b228aaf628aad55ee464b1f094ab3a
Author: Joseph Turner <joseph@ushin.org>
Commit: Adam Porter <adam@alphapapa.net>
Change: (hyperdrive-mirror.el) Compare file modification times
Display the file "status" in the hyperdrive mirror buffer, one
of ("new" "changed" "same"). Status is determined by a comparison of
hyperdrive and local mtime. hyperdrive--mirror now only uploads files
which are new or have been uploaded.
---
hyperdrive-mirror.el | 41 +++++++++++++++++++++++++++++------------
1 file changed, 29 insertions(+), 12 deletions(-)
diff --git a/hyperdrive-mirror.el b/hyperdrive-mirror.el
index 8baf041dff..dcc54da5fa 100644
--- a/hyperdrive-mirror.el
+++ b/hyperdrive-mirror.el
@@ -47,8 +47,12 @@
FILES-AND-URLS is structured like `tabulated-list-entries'. After
uploading files, open PARENT-ENTRY."
(let* ((count 0)
+ (upload-files-and-urls (cl-remove-if (pcase-lambda (`(,_id [,status
,_file ,_url]))
+ ;; Exclude files which have
not been changed.
+ (equal status "same"))
+ files-and-urls))
(progress-reporter
- (make-progress-reporter (format "Uploading %s files: " (length
files-and-urls)) 0 (length files-and-urls)))
+ (make-progress-reporter (format "Uploading %s files: " (length
upload-files-and-urls)) 0 (length upload-files-and-urls)))
(queue (make-plz-queue
:limit hyperdrive-queue-size
:finally (lambda ()
@@ -56,7 +60,7 @@ uploading files, open PARENT-ENTRY."
(hyperdrive-open parent-entry)
(with-current-buffer (get-buffer-create
"*hyperdrive-mirror*")
(setq-local hyperdrive-mirror-already-uploaded
t))))))
- (pcase-dolist (`(,_id [,file ,url]) files-and-urls)
+ (pcase-dolist (`(,_id [,status ,file ,url]) upload-files-and-urls)
(hyperdrive-upload-file file (hyperdrive-url-entry url)
:queue queue
;; TODO: Error handling (e.g. in case one or more files fails to
upload).
@@ -65,9 +69,6 @@ uploading files, open PARENT-ENTRY."
;;;; Commands
-;; TODO: Don't overwrite a hyperdrive file with the same
-;; contents. Should we keep a cache of uploaded files and mtimes?
-
;;;###autoload
(cl-defun hyperdrive-mirror
(source hyperdrive &key target-dir (predicate #'always) no-confirm)
@@ -135,12 +136,27 @@ predicate and set NO-CONFIRM to t."
(files-and-urls
;; Structured according to `tabulated-list-entries'
(mapcar (lambda (file)
- (let ((url (hyperdrive-entry-url
- (hyperdrive-entry-create
- :hyperdrive hyperdrive
- :path (expand-file-name (file-relative-name
file source) target-dir)
- :encode t))))
- (list url (vector file url))))
+ (let* ((entry (hyperdrive-entry-create
+ :hyperdrive hyperdrive
+ :path (expand-file-name (file-relative-name
file source) target-dir)
+ :encode t))
+ (status (condition-case err
+ (if (time-less-p
(hyperdrive-entry-modified (hyperdrive-fill entry :then 'sync))
+
(file-attribute-modification-time (file-attributes file)))
+ ;; TODO: Propertize status strings.
+ "changed"
+ "same")
+ (plz-error
+ (pcase (caddr err)
+ ((app plz-error-response (cl-struct
plz-response (status 404) body))
+ ;; Entry doesn't exist: Set `status'
to `new'.
+
(hyperdrive-update-nonexistent-version-range entry)
+ "new")
+ (_
+ ;; Re-signal error.
+ (signal (car err) (cdr err)))))))
+ (url (hyperdrive-entry-url entry)))
+ (list url (vector status file url))))
files)))
(unless files
(hyperdrive-user-error "No files selected for mirroring (double-check
predicate)"))
@@ -175,7 +191,8 @@ predicate and set NO-CONFIRM to t."
:group 'hyperdrive
:interactive nil
;; TODO: When possible, use vtable.el (currently only available in Emacs
>=29)
- (setq tabulated-list-format [("From file" 60 t)
+ (setq tabulated-list-format [("Status" 7 t)
+ ("From file" 60 t)
("To URL" 60 t)])
(tabulated-list-init-header))
- [nongnu] elpa/hyperdrive updated (b5651bcfd1 -> 24df174711), ELPA Syncer, 2023/09/08
- [nongnu] elpa/hyperdrive d7ad2d87e2 02/13: Change: (hyperdrive-mirror) Add faces for each status, ELPA Syncer, 2023/09/08
- [nongnu] elpa/hyperdrive 96326a0222 06/13: Fix: (hyperdrive--mirror) Signal user-error when no files to upload, ELPA Syncer, 2023/09/08
- [nongnu] elpa/hyperdrive bc622823e6 10/13: Tidy: Function call, ELPA Syncer, 2023/09/08
- [nongnu] elpa/hyperdrive 4a6296f10f 09/13: Comment: Add NOTE, ELPA Syncer, 2023/09/08
- [nongnu] elpa/hyperdrive 1423b9b8f2 08/13: Comment: Add TODO, ELPA Syncer, 2023/09/08
- [nongnu] elpa/hyperdrive 0d6ad70c0c 03/13: Add: (hyperdrive-mirror.el) Add revert-buffer-function, ELPA Syncer, 2023/09/08
- [nongnu] elpa/hyperdrive 2ce5f9c3a9 01/13: Change: (hyperdrive-mirror.el) Compare file modification times,
ELPA Syncer <=
- [nongnu] elpa/hyperdrive 39475924c0 04/13: Change: (hyperdrive-mirror) Distinguish older files from same mtime, ELPA Syncer, 2023/09/08
- [nongnu] elpa/hyperdrive 0591645ed8 05/13: Comment: Add TODO, ELPA Syncer, 2023/09/08
- [nongnu] elpa/hyperdrive a71bea29a8 07/13: Comment: Update TODO, ELPA Syncer, 2023/09/08
- [nongnu] elpa/hyperdrive be7dc28786 11/13: Tidy: (hyperdrive-next-version) Use if instead of pcase, ELPA Syncer, 2023/09/08
- [nongnu] elpa/hyperdrive 114bc1e7bc 12/13: Tidy, ELPA Syncer, 2023/09/08
- [nongnu] elpa/hyperdrive 24df174711 13/13: Merge branch 'mirror-compare-mtime', ELPA Syncer, 2023/09/08