branch: elpa-admin commit b776ff998db382bde8b244e06304d1b620fd8829 Author: Stefan Monnier <monn...@iro.umontreal.ca> Commit: Stefan Monnier <monn...@iro.umontreal.ca>
* elpa-admin.el (elpaa--prune-old-tarballs): Move the .sig files as well Also fix use of destructively-modified list and demote errors. --- elpa-admin.el | 60 +++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/elpa-admin.el b/elpa-admin.el index b56bc48..4501ba5 100644 --- a/elpa-admin.el +++ b/elpa-admin.el @@ -424,30 +424,42 @@ Do it without leaving the current branch." (let ((self (rassoc (file-name-nondirectory tarball) oldtarballs))) (when self (setq oldtarballs (delq self oldtarballs)))) - (when (nthcdr elpaa--keep-max oldtarballs) - (let* ((keep (elpaa--keep-old oldtarballs elpaa--keep-max)) - (skeep (nreverse (sort keep - (lambda (t1 t2) (version<= (car t1) (car t2))))))) - (message "Keeping: %s" (mapcar #'cdr skeep)) - (dolist (oldtarball oldtarballs) - (unless (memq oldtarball keep) - (cl-assert (not (equal (cdr oldtarball) - (file-name-nondirectory tarball)))) - (message "Deleting %s" (cdr oldtarball)) - (let ((oldd (expand-file-name "old" destdir))) - (make-directory oldd t) - (rename-file (expand-file-name (cdr oldtarball) destdir) - (expand-file-name (cdr oldtarball) oldd))))) - (setq oldtarballs skeep))) - (dolist (oldtarball oldtarballs) - ;; Compress oldtarballs. - (let ((file (cdr oldtarball))) - (when (string-match "\\.\\(tar\\|el\\)\\'" file) - ;; Make sure we don't compress the file we just created. - (cl-assert (not (equal file (file-name-nondirectory tarball)))) - ;; (elpaa--message "not equal %s and %s" file tarball) - (elpaa--call nil "lzip" (expand-file-name file destdir)) - (setf (cdr oldtarball) (concat file ".lz"))))) + (with-demoted-errors "elpaa--prune-old-tarballs: %S" + (when (nthcdr elpaa--keep-max oldtarballs) + (let* ((keep (elpaa--keep-old oldtarballs elpaa--keep-max)) + (keep (nreverse (sort keep + (lambda (t1 t2) (version<= (car t1) (car t2))))))) + (message "Keeping: %s" (mapcar #'cdr keep)) + (dolist (oldtarball oldtarballs) + (unless (memq oldtarball keep) + (cl-assert (not (equal (cdr oldtarball) + (file-name-nondirectory tarball)))) + (message "Deleting %s" (cdr oldtarball)) + (let* ((olddir (expand-file-name "old" destdir)) + (filename (cdr oldtarball)) + (basename (file-name-sans-extension filename)) + (sig (concat (if (member (file-name-extension filename) + '("lz" "gz")) + (file-name-sans-extension basename) + basename) + ".sig")) + (mvfun (lambda (f) + (let ((src (expand-file-name f destdir))) + (when (file-exists-p src) + (rename-file src (expand-file-name olddir))))))) + (make-directory olddir t) + (funcall mvfun filename) + (funcall mvfun sig)))) + (setq oldtarballs keep))) + (dolist (oldtarball oldtarballs) + ;; Compress oldtarballs. + (let ((file (cdr oldtarball))) + (when (string-match "\\.\\(tar\\|el\\)\\'" file) + ;; Make sure we don't compress the file we just created. + (cl-assert (not (equal file (file-name-nondirectory tarball)))) + ;; (elpaa--message "not equal %s and %s" file tarball) + (elpaa--call nil "lzip" (expand-file-name file destdir)) + (setf (cdr oldtarball) (concat file ".lz")))))) oldtarballs) (defun elpaa--make-one-tarball ( tarball dir pkg-spec metadata