Skip to content

Commit

Permalink
Fix import/export bug when sha384 or sha512 are null
Browse files Browse the repository at this point in the history
fixes #7836
  • Loading branch information
David Davis committed Dec 10, 2020
1 parent a69eb16 commit ea18d8d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES/7836.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed Pulp import/export bug that occurs when sha384 or sha512 is not in ``ALLOWED_CONTENT_CHECKSUMS``.
16 changes: 16 additions & 0 deletions pulpcore/app/modelresource.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@
# repo-version-specific.
#
class ArtifactResource(QueryModelResource):
def before_import_row(self, row, **kwargs):
"""
Sets sha384 and sha512 to None if they are blank strings.
Args:
row (tablib.Dataset row): incoming import-row representing a single Variant.
kwargs: args passed along from the import() call.
"""
# the export converts None to blank strings but sha384 and sha512 have unique constraints
# that get triggered if they are blank. convert them back into None if they are blank.
if row["sha384"] == "":
row["sha384"] = None
if row["sha512"] == "":
row["sha512"] = None

class Meta:
model = Artifact
exclude = (
Expand Down

0 comments on commit ea18d8d

Please sign in to comment.