[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/hyperdrive edd5eb8a06 15/31: Add/Change: (cl-defstruct hyp
|
From: |
ELPA Syncer |
|
Subject: |
[nongnu] elpa/hyperdrive edd5eb8a06 15/31: Add/Change: (cl-defstruct hyperdrive-mirror-item) |
|
Date: |
Fri, 3 Nov 2023 22:00:47 -0400 (EDT) |
branch: elpa/hyperdrive
commit edd5eb8a06d921cc6b78b9d7b046c489f71dab6d
Author: Adam Porter <adam@alphapapa.net>
Commit: Adam Porter <adam@alphapapa.net>
Add/Change: (cl-defstruct hyperdrive-mirror-item)
---
hyperdrive-mirror.el | 37 ++++++++++++++++++++++++++-----------
1 file changed, 26 insertions(+), 11 deletions(-)
diff --git a/hyperdrive-mirror.el b/hyperdrive-mirror.el
index fee2d9e976..2e1634977d 100644
--- a/hyperdrive-mirror.el
+++ b/hyperdrive-mirror.el
@@ -32,6 +32,16 @@
(require 'taxy-magit-section)
+;;;; Structs
+
+(cl-defstruct hyperdrive-mirror-item
+ "Represents a potential mirror operation for a file."
+ (file nil :documentation "Local filename.")
+ (url nil :documentation "Hyperdrive URL.")
+ (status nil :documentation "One of `new', `newer', `older', `same'.
+Comparison of the timestamps of the local file and the hyperdrive
+file."))
+
;;;; Variables
;; TODO: Consolidate these two local variables into one?
@@ -63,7 +73,7 @@ STATUS is one of:
hyperdrive-mirror-keys "hyperdrive-mirror-key" "Grouping keys."))
(hyperdrive-mirror-define-key status ()
- (pcase-let ((`(,_file ,_url ,item-status) item))
+ (pcase-let (((cl-struct hyperdrive-mirror-item file url (status
item-status)) item))
(pcase-exhaustive item-status
(`new (propertize "New locally" 'face 'hyperdrive-mirror-new))
(`newer (propertize "Newer locally" 'face 'hyperdrive-mirror-newer))
@@ -82,11 +92,11 @@ STATUS is one of:
(taxy-magit-section-define-column-definer "hyperdrive-mirror"))
(hyperdrive-mirror-define-column "Local File" ()
- (pcase-let* ((`(,file ,_url ,_status) item))
+ (pcase-let (((cl-struct hyperdrive-mirror-item file) item))
file))
(hyperdrive-mirror-define-column "Hyperdrive File" ()
- (pcase-let* ((`(,_file ,url ,_status) item))
+ (pcase-let (((cl-struct hyperdrive-mirror-item url) item))
url))
(unless hyperdrive-mirror-columns
@@ -101,9 +111,10 @@ STATUS is one of:
FILES-AND-URLS is structured like `hyperdrive-mirror-files-and-urls'.
After uploading files, open PARENT-ENTRY."
(let* ((count 0)
- (upload-files-and-urls (cl-remove-if-not (pcase-lambda (`(,_file
,_url ,status))
- (or (eq status 'new) (eq
status 'newer)))
- files-and-urls))
+ (upload-files-and-urls (cl-remove-if-not
+ (pcase-lambda ((cl-struct
hyperdrive-mirror-item status))
+ (or (eq status 'new) (eq status 'newer)))
+ files-and-urls))
(progress-reporter
(make-progress-reporter (format "Uploading %s files: " (length
upload-files-and-urls)) 0 (length upload-files-and-urls)))
(queue (make-plz-queue
@@ -115,7 +126,7 @@ After uploading files, open PARENT-ENTRY."
(revert-buffer nil t))))))
(unless upload-files-and-urls
(hyperdrive-user-error "No new/newer files to upload"))
- (pcase-dolist (`(,file ,url ,_status) upload-files-and-urls)
+ (pcase-dolist ((cl-struct hyperdrive-mirror-item 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).
@@ -206,7 +217,8 @@ predicate and set NO-CONFIRM to t."
(hyperdrive-mirror--metadata-finally
buffer
(sort files-and-urls
- (pcase-lambda (`(,a-file ,_ ,_) `(,b-file
,_ ,_))
+ (pcase-lambda ((cl-struct
hyperdrive-mirror-item (file a-file))
+ (cl-struct
hyperdrive-mirror-item (file b-file)))
(string< a-file b-file)))))))
(dolist (file files)
(let ((entry (hyperdrive-entry-create
@@ -221,7 +233,8 @@ predicate and set NO-CONFIRM to t."
((time-equal-p drive-mtime
local-mtime) 'same)
(t 'older)))
(url (hyperdrive-entry-url entry)))
- (push (list file url status) files-and-urls)
+ (push (make-hyperdrive-mirror-item :file file :url
url :status status)
+ files-and-urls)
(update-progress (cl-incf num-filled) num-of)))
:else (lambda (plz-error)
(let ((status-code (plz-response-status
(plz-error-response plz-error))))
@@ -229,7 +242,9 @@ predicate and set NO-CONFIRM to t."
(404 ;; Entry doesn't exist: Set `status' to
`new'".
;; TODO: Consider moving
`hyperdrive-update-nonexistent-version-range' call...
(hyperdrive-update-nonexistent-version-range
entry)
- (push (list file (hyperdrive-entry-url entry)
'new) files-and-urls)
+ (push (make-hyperdrive-mirror-item
+ :file file :url (hyperdrive-entry-url
entry) :status 'new)
+ files-and-urls)
(update-progress (cl-incf num-filled) num-of))
(_
(hyperdrive-error "Unable to get metadata for
URL \"%s\": %S"
@@ -303,7 +318,7 @@ KEYS should be a list of grouping keys, as in
;; taxy-key to `new', `newer', `older', or `same' and then
;; compare keys instead?
#'taxy-name)
- (taxy-mapcar (pcase-lambda (`(,file ,url ,status))
+ (taxy-mapcar (pcase-lambda ((cl-struct hyperdrive-mirror-item
file url status))
(list (abbreviate-file-name file) url
status)))))
(format-cons
(taxy-magit-section-format-items
- [nongnu] elpa/hyperdrive db6d7995f2 09/31: Change: (hyperdrive-mirror) Change column names, (continued)
- [nongnu] elpa/hyperdrive db6d7995f2 09/31: Change: (hyperdrive-mirror) Change column names, ELPA Syncer, 2023/11/03
- [nongnu] elpa/hyperdrive f0db6b58c7 11/31: Change: (hyperdrive-mirror--insert-taxy) Abbreviate display filename, ELPA Syncer, 2023/11/03
- [nongnu] elpa/hyperdrive a21138bc87 13/31: Docs: Document that only new and newer files are uploaded w/ mirror, ELPA Syncer, 2023/11/03
- [nongnu] elpa/hyperdrive e9e4630f54 14/31: Meta: Update CHANGELOG, ELPA Syncer, 2023/11/03
- [nongnu] elpa/hyperdrive 1120cb6e29 16/31: Change: (hyperdrive-mirror) Show uploadable/non-uploadable separately, ELPA Syncer, 2023/11/03
- [nongnu] elpa/hyperdrive 6321fdc675 01/31: Change: (hyperdrive-mirror) Use taxy-magit-section, ELPA Syncer, 2023/11/03
- [nongnu] elpa/hyperdrive f201aedb5e 08/31: Change: (hyperdrive-mirror-files-and-urls) Use symbols, not strings, ELPA Syncer, 2023/11/03
- [nongnu] elpa/hyperdrive 471517e574 17/31: Add names, ELPA Syncer, 2023/11/03
- [nongnu] elpa/hyperdrive e9614f01c3 22/31: Tidy: Remove commented code, ELPA Syncer, 2023/11/03
- [nongnu] elpa/hyperdrive 74a701b164 30/31: Change: (hyperdrive--mirror) Kill mirror buffer after mirroring, ELPA Syncer, 2023/11/03
- [nongnu] elpa/hyperdrive edd5eb8a06 15/31: Add/Change: (cl-defstruct hyperdrive-mirror-item),
ELPA Syncer <=
- [nongnu] elpa/hyperdrive 35dbbd86f8 06/31: Change: (hyperdrive-mirror) Remove Status column, ELPA Syncer, 2023/11/03
- [nongnu] elpa/hyperdrive 579d678da7 20/31: Change: Inherit from built-in faces for hyperdrive-mirror-* faces, ELPA Syncer, 2023/11/03
- [nongnu] elpa/hyperdrive 2c38208541 23/31: Comment: Update TODO, ELPA Syncer, 2023/11/03
- [nongnu] elpa/hyperdrive de24c7fffe 31/31: Merge branch 'wip/send-last-modified-header', ELPA Syncer, 2023/11/03
- [nongnu] elpa/hyperdrive 21e55d694e 04/31: Change: (hyperdrive-mirror-files-and-urls) Use plain list, ELPA Syncer, 2023/11/03
- [nongnu] elpa/hyperdrive 93520312ef 05/31: Tidy: (hyperdrive-mirror) Minor optimization, ELPA Syncer, 2023/11/03
- [nongnu] elpa/hyperdrive c47693ff5a 07/31: Tidy: (hyperdrive-mirror-define-key) Don't accept arguments, ELPA Syncer, 2023/11/03
- [nongnu] elpa/hyperdrive 17f3cde160 10/31: Change: (hyperdrive-mirror--insert-taxy) Sort taxys, ELPA Syncer, 2023/11/03
- [nongnu] elpa/hyperdrive 4c44d4fae0 12/31: Tidy: (hyperdrive-mirror-files-and-urls) Reorder format, ELPA Syncer, 2023/11/03
- [nongnu] elpa/hyperdrive e2a76f0b66 18/31: Fix: Abbreviate file name only for display in column, ELPA Syncer, 2023/11/03