From 5ece19843251e17a1a5b13ae31ba3ba79e1ed6d8 Mon Sep 17 00:00:00 2001 From: Jono Yang Date: Thu, 2 Nov 2023 18:48:53 -0700 Subject: [PATCH] Exclude the package we are looking at Signed-off-by: Jono Yang --- packagedb/management/commands/update_maven_download_urls.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packagedb/management/commands/update_maven_download_urls.py b/packagedb/management/commands/update_maven_download_urls.py index 36d50623..9402196a 100644 --- a/packagedb/management/commands/update_maven_download_urls.py +++ b/packagedb/management/commands/update_maven_download_urls.py @@ -242,7 +242,7 @@ def handle(self, *args, **options): qualifiers=package_url.qualifiers, ) generated_download_url = urls['repository_download_url'] - if Package.objects.filter(download_url=generated_download_url).exists(): + if Package.objects.filter(download_url=generated_download_url).exclude(pk=package.pk).exists(): # This download url already exists in the database, we should just remove this record. packages_to_delete.append(package) logger.info(f'Deleting {package.package_uid} - already exists in database') @@ -263,7 +263,7 @@ def handle(self, *args, **options): and package.name.lower() == artifact.name.lower() and package.version.lower() == artifact.version.lower() ): - if Package.objects.filter(download_url=artifact.download_url).exists(): + if Package.objects.filter(download_url=artifact.download_url).exclude(pk=package.pk).exists(): packages_to_delete.append(package) logger.info(f'Deleting {package.package_uid} - already exists in database') else: