Stefan Monnier <monnier@iro.umontreal.ca> writes: >> No, you are absolutely right, I just didn't see that. >> >> From 62fa93b120f664f1be44c1194f701a1c5d965f2a Mon Sep 17 00:00:00 2001 >> From: Philip Kaludercic <philipk@posteo.net> >> Date: Mon, 31 Oct 2022 17:01:07 +0100 >> Subject: [PATCH 1/2] Remove deleted packages from archive-contents >> >> * elpa-admin.el (elpaa--write-archive-contents): Extract from >> 'elpaa--update-archive-contents' >> (elpaa--update-archive-contents): Use 'elpaa--write-archive-contents'. >> (elpaa--scrub-archive-contents): Add function. >> (elpaa-batch-make-all-packages): Call 'elpaa--scrub-archive-contents'. >> --- >> elpa-admin.el | 31 ++++++++++++++++++++++++++----- >> 1 file changed, 26 insertions(+), 5 deletions(-) >> >> diff --git a/elpa-admin.el b/elpa-admin.el >> index c03fea47a1..12306ec818 100644 >> --- a/elpa-admin.el >> +++ b/elpa-admin.el >> @@ -154,6 +154,14 @@ Delete backup files also." >> (backup-file-name-p f)) >> (delete-file f))))) >> >> +(defun elpaa--write-archive-contents (ac dir) >> + "Write archive contents AC into directory DIR." >> + (with-temp-buffer >> + (pp ac (current-buffer)) >> + (write-region nil nil (expand-file-name "archive-contents" dir))) >> + (let ((default-directory (expand-file-name dir))) >> + (elpaa--html-make-index (cdr ac)))) >> + >> (defun elpaa--update-archive-contents (pkg-desc dir) >> "Update the `archive-contents' file in DIR with new package PKG-DESC." >> (let* ((filename (expand-file-name "archive-contents" dir)) >> @@ -166,11 +174,7 @@ Delete backup files also." >> (lambda (x y) >> (string-lessp (symbol-name (car x)) (symbol-name >> (car y)))))) >> (elpaa--message "new AC: %S" ac) >> - (with-temp-buffer >> - (pp ac (current-buffer)) >> - (write-region nil nil filename) >> - (let ((default-directory (expand-file-name dir))) >> - (elpaa--html-make-index (cdr ac)))))) >> + (elpaa--write-archive-contents ac dir))) >> >> (defun elpaa--get-specs () >> (elpaa--form-from-file-contents elpaa--specs-file)) >> @@ -788,6 +792,21 @@ of the current `process-environment'. Return the >> modified copy." >> (list pkgname)) >> spec))) >> >> +(defun elpaa--scrub-archive-contents (dir specs) >> + "Remove dead packages from archive contents in DIR. >> +SPECS is the list of package specifications." >> + (let* ((filename (expand-file-name "archive-contents" dir)) >> + (ac (if (file-exists-p filename) >> + (elpaa--form-from-file-contents filename) >> + '(1)))) >> + (elpaa--write-archive-contents >> + (cons (car ac) >> + (mapcan >> + (lambda (pkg) >> + (and (assoc (car pkg) specs #'string=) (list pkg))) >> + (cdr ac))) >> + dir))) > > LGTM. Feel free to push. Will do. > Just one comment: we could skip the > `elpaa--write-archive-contents` (and associated > `elpaa--html-make-index`) in the overwhelmingly common case where > nothing was scrubbed. Good point. > > Stefan
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4