Skip to content

Commit

Permalink
Allow avatar download to fail on checksum
Browse files Browse the repository at this point in the history
[noissue]
  • Loading branch information
mdellweg committed Feb 20, 2024
1 parent 88577d3 commit 07eabfa
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES/+failsafe_avatar.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Changed avatar download to allow graceful failure on mismatching image checksum.
3 changes: 2 additions & 1 deletion pulp_ansible/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,8 @@ def calculate_metadata_sha256(self):
# If we are creating from sync, assert that calculated hash == synced hash
if self.metadata_sha256 != hasher.hexdigest():
raise IntegrityError("Calculated digest does not equal passed in digest")
self.metadata_sha256 = hasher.hexdigest()
else:
self.metadata_sha256 = hasher.hexdigest()

class Meta:
default_related_name = "%(app_label)s_%(model_name)s"
Expand Down
3 changes: 2 additions & 1 deletion pulp_ansible/app/tasks/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from galaxy_importer.collection import sync_collection
from galaxy_importer.exceptions import ImporterError
from git import GitCommandError, Repo
from pulpcore.plugin.exceptions import DigestValidationError
from pulpcore.plugin.models import (
Artifact,
ContentArtifact,
Expand Down Expand Up @@ -1067,7 +1068,7 @@ async def download(self):
artifact_copy = self.artifact
try:
return await super().download()
except ClientError as e:
except (ClientError, DigestValidationError) as e:
# Reset DA so that future stages can properly handle it
self.artifact = artifact_copy
self.deferred_download = True
Expand Down

0 comments on commit 07eabfa

Please sign in to comment.