From 090d82ee1d25fe0c4b733153e2e09b57ddd62de7 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Sun, 20 Jun 2021 20:46:38 +0200 Subject: [PATCH] Add deletion for old sonames Old sonames are automatically removed as packages are updated and not removed and re-added once updated. So we'll have to figure out the difference between the new and old sonames list and delete those sonames. --- devel/management/commands/readlinks.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/devel/management/commands/readlinks.py b/devel/management/commands/readlinks.py index 7085da2b..aeb49d2c 100644 --- a/devel/management/commands/readlinks.py +++ b/devel/management/commands/readlinks.py @@ -88,11 +88,21 @@ def read_links(repopath): files_data = repodb.extractfile(tarinfo) old_sonames = Soname.objects.filter(pkg=dbpkg) + pkg_sonames = [] + found_sonames = [] + for soname in files_data: soname = soname.strip().decode() # New soname which we do not track yet for this package if not old_sonames.filter(name=soname): - sonames.append(Soname(pkg=dbpkg, name=soname)) + pkg_sonames.append(Soname(pkg=dbpkg, name=soname)) + + found_sonames.append(soname) + + # Clean up sonames which are not linked to the package anymore + old_sonames.exclude(name__in=found_sonames).delete() + + sonames.extend(pkg_sonames) if sonames: Soname.objects.bulk_create(sonames)