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.
This commit is contained in:
Jelle van der Waa 2021-06-20 20:46:38 +02:00
parent 3f807c8e18
commit 090d82ee1d
No known key found for this signature in database
GPG Key ID: C06086337C50773E

View File

@ -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)