[projects/pld-ftp-admin] clean-dups.py: keep every version when one cannot be read
arekm
arekm at pld-linux.org
Sat Oct 24 11:44:47 CEST 2026
commit a00ecd6476560a7e05fa09235af3a90b0c527cb2
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Sat Oct 24 10:55:47 2026 +0200
clean-dups.py: keep every version when one cannot be read
An unreadable package compared as equal to the others, so the newest
version could be the one removed.
wwwbin/clean-dups.py | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
---
diff --git a/wwwbin/clean-dups.py b/wwwbin/clean-dups.py
index da96848..a5c336a 100755
--- a/wwwbin/clean-dups.py
+++ b/wwwbin/clean-dups.py
@@ -53,34 +53,32 @@ ignore = re.compile(r'^(kernel-.*)$')
ts = rpm.TransactionSet("", (rpm.RPMVSF_NOHDRCHK | rpm.RPMVSF_NEEDPAYLOAD | rpm.RPMVSF_MASK_NODIGESTS | rpm.RPMVSF_MASK_NOSIGNATURES))
+class CompareError(Exception):
+ pass
+
def compare(f1, f2):
try:
fd1 = os.open(os.path.join(dir, f1), os.O_RDONLY)
except Exception as e:
- print(e)
- # ignore non-files
- return 0
+ raise CompareError(e)
try:
fd2 = os.open(os.path.join(dir, f2), os.O_RDONLY)
except Exception as e:
- print(e)
- # ignore non-files
- return 0
+ os.close(fd1)
+ raise CompareError(e)
try:
h1 = ts.hdrFromFdno(fd1)
except Exception as e:
- print("hdrFromFdno for %s failed: %s" % (f1, e))
os.close(fd1)
os.close(fd2)
- return 0
+ raise CompareError("hdrFromFdno for %s failed: %s" % (f1, e))
try:
h2 = ts.hdrFromFdno(fd2)
except Exception as e:
- print("hdrFromFdno for %s failed: %s" % (f2, e))
os.close(fd1)
os.close(fd2)
- return 0
+ raise CompareError("hdrFromFdno for %s failed: %s" % (f2, e))
os.close(fd1)
os.close(fd2)
@@ -106,7 +104,11 @@ def find_old(files):
def find_dupes(dupes):
pkgs = []
for old in dupes:
- pkgs.extend(find_old(old))
+ # an order with an unreadable file in it is arbitrary and could drop the newest version
+ try:
+ pkgs.extend(find_old(old))
+ except CompareError as e:
+ print("%s; keeping %s" % (e, ' '.join(old)))
return pkgs
files = {}
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/projects/pld-ftp-admin.git/commitdiff/e14cb7d4d74f8bdd9368d9645ecaf49593cf6335
More information about the pld-cvs-commit
mailing list