We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[PR #5443/c7079c89 backport][3.54] Pin the pytest-redis requirement for unit tests
**This is a backport of PR #5443 as merged into main (c7079c891b87ecd9073260db5baa35826803f635).**

[noissue]

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `pulpcore/app/serializers/content.py`
Content:
```
1 import hashlib
2 from gettext import gettext as _
3 
4 from django.db import transaction
5 from rest_framework import serializers
6 from rest_framework.validators import UniqueValidator
7 
8 from pulpcore.app import models
9 from pulpcore.app.serializers import base, fields
10 
11 UNIQUE_ALGORITHMS = ['sha256', 'sha384', 'sha512']
12 
13 
14 class BaseContentSerializer(base.MasterModelSerializer):
15     _href = base.DetailIdentityField()
16 
17     class Meta:
18         model = models.Content
19         fields = base.MasterModelSerializer.Meta.fields
20 
21 
22 class NoArtifactContentSerializer(BaseContentSerializer):
23 
24     class Meta:
25         model = models.Content
26         fields = BaseContentSerializer.Meta.fields
27 
28 
29 class SingleArtifactContentSerializer(BaseContentSerializer):
30     artifact = fields.SingleContentArtifactField(
31         help_text=_("Artifact file representing the physical content"),
32     )
33 
34     relative_path = serializers.CharField(
35         help_text=_("Path where the artifact is located relative to distributions base_path"),
36         validators=[fields.relative_path_validator],
37         write_only=True,
38     )
39 
40     def __init__(self, *args, **kwargs):
41         """
42         Initializer for SingleArtifactContentSerializer
43         """
44         super().__init__(*args, **kwargs)
45 
46         # If the content model has its own database field 'relative_path',
47         # we should not mark the field write_only
48         if hasattr(self.Meta.model, 'relative_path') and "relative_path" in self.fields:
49             self.fields["relative_path"].write_only = False
50 
51     @transaction.atomic
52     def create(self, validated_data):
53         """
54         Create the content and associate it with its Artifact.
55 
56         Args:
57             validated_data (dict): Data to save to the database
58         """
59         artifact = validated_data.pop('artifact')
60         if "relative_path" in self.fields and self.fields["relative_path"].write_only:
61             relative_path = validated_data.pop('relative_path')
62         else:
63             relative_path = validated_data.get('relative_path')
64         content = self.Meta.model.objects.create(**validated_data)
65         models.ContentArtifact.objects.create(
66             artifact=artifact,
67             content=content,
68             relative_path=relative_path,
69         )
70         return content
71 
72     class Meta:
73         model = models.Content
74         fields = BaseContentSerializer.Meta.fields + ('artifact', 'relative_path')
75 
76 
77 class MultipleArtifactContentSerializer(BaseContentSerializer):
78     artifacts = fields.ContentArtifactsField(
79         help_text=_("A dict mapping relative paths inside the Content to the corresponding"
80                     "Artifact URLs. E.g.: {'relative/path': "
81                     "'/artifacts/1/'"),
82     )
83 
84     @transaction.atomic
85     def create(self, validated_data):
86         """
87         Create the content and associate it with all its Artifacts.
88 
89         Args:
90             validated_data (dict): Data to save to the database
91         """
92         artifacts = validated_data.pop('artifacts')
93         content = self.Meta.model.objects.create(**validated_data)
94         for relative_path, artifact in artifacts.items():
95             models.ContentArtifact.objects.create(
96                 artifact=artifact,
97                 content=content,
98                 relative_path=relative_path,
99             )
100         return content
101 
102     class Meta:
103         model = models.Content
104         fields = BaseContentSerializer.Meta.fields + ('artifacts',)
105 
106 
107 class ContentChecksumSerializer(serializers.Serializer):
108     """
109     Provide a serializer with artifact checksum fields for single artifact content.
110 
111     If you use this serializer, it's recommended that you prefetch artifacts:
112 
113         Content.objects.prefetch_related("_artifacts").all()
114     """
115 
116     md5 = fields.ContentArtifactChecksumField(
117         help_text=_("The MD5 checksum if available."),
118         checksum='md5',
119     )
120 
121     sha1 = fields.ContentArtifactChecksumField(
122         help_text=_("The SHA-1 checksum if available."),
123         checksum='sha1',
124     )
125 
126     sha224 = fields.ContentArtifactChecksumField(
127         help_text=_("The SHA-224 checksum if available."),
128         checksum='sha224',
129     )
130 
131     sha256 = fields.ContentArtifactChecksumField(
132         help_text=_("The SHA-256 checksum if available."),
133         checksum='sha256',
134     )
135 
136     sha384 = fields.ContentArtifactChecksumField(
137         help_text=_("The SHA-384 checksum if available."),
138         checksum='sha384',
139     )
140 
141     sha512 = fields.ContentArtifactChecksumField(
142         help_text=_("The SHA-512 checksum if available."),
143         checksum='sha512',
144     )
145 
146     class Meta:
147         model = models.Content
148         fields = base.ModelSerializer.Meta.fields + ('md5', 'sha1', 'sha224', 'sha256', 'sha384',
149                                                      'sha512')
150 
151 
152 class ArtifactSerializer(base.ModelSerializer):
153     _href = base.IdentityField(
154         view_name='artifacts-detail',
155     )
156 
157     file = serializers.FileField(
158         help_text=_("The stored file."),
159         allow_empty_file=True,
160         required=False
161     )
162 
163     size = serializers.IntegerField(
164         help_text=_("The size of the file in bytes."),
165         required=False
166     )
167 
168     md5 = serializers.CharField(
169         help_text=_("The MD5 checksum of the file if available."),
170         required=False,
171         allow_null=True,
172     )
173 
174     sha1 = serializers.CharField(
175         help_text=_("The SHA-1 checksum of the file if available."),
176         required=False,
177         allow_null=True,
178     )
179 
180     sha224 = serializers.CharField(
181         help_text=_("The SHA-224 checksum of the file if available."),
182         required=False,
183         allow_null=True,
184     )
185 
186     sha256 = serializers.CharField(
187         help_text=_("The SHA-256 checksum of the file if available."),
188         required=False,
189         allow_null=True,
190     )
191 
192     sha384 = serializers.CharField(
193         help_text=_("The SHA-384 checksum of the file if available."),
194         required=False,
195         allow_null=True,
196     )
197 
198     sha512 = serializers.CharField(
199         help_text=_("The SHA-512 checksum of the file if available."),
200         required=False,
201         allow_null=True,
202     )
203 
204     def validate(self, data):
205         """
206         Validate file by size and by all checksums provided.
207 
208         Args:
209             data (:class:`django.http.QueryDict`): QueryDict mapping Artifact model fields to their
210                 values
211 
212         Raises:
213             :class:`rest_framework.exceptions.ValidationError`: When the expected file size or any
214                 of the checksums don't match their actual values.
215         """
216         super().validate(data)
217 
218         if 'size' in data:
219             if data['file'].size != int(data['size']):
220                 raise serializers.ValidationError(_("The size did not match actual size of file."))
221         else:
222             data['size'] = data['file'].size
223 
224         for algorithm in hashlib.algorithms_guaranteed:
225             if algorithm in models.Artifact.DIGEST_FIELDS:
226                 digest = data['file'].hashers[algorithm].hexdigest()
227 
228                 if algorithm in data and digest != data[algorithm]:
229                     raise serializers.ValidationError(_("The %s checksum did not match.")
230                                                       % algorithm)
231                 else:
232                     data[algorithm] = digest
233                 if algorithm in UNIQUE_ALGORITHMS:
234                     validator = UniqueValidator(models.Artifact.objects.all(),
235                                                 message=_("{0} checksum must be "
236                                                           "unique.").format(algorithm))
237                     validator.field_name = algorithm
238                     validator.instance = None
239                     validator(digest)
240         return data
241 
242     class Meta:
243         model = models.Artifact
244         fields = base.ModelSerializer.Meta.fields + ('file', 'size', 'md5', 'sha1', 'sha224',
245                                                      'sha256', 'sha384', 'sha512')
246
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/pulpcore/app/serializers/content.py b/pulpcore/app/serializers/content.py
--- a/pulpcore/app/serializers/content.py
+++ b/pulpcore/app/serializers/content.py
@@ -57,7 +57,7 @@
             validated_data (dict): Data to save to the database
         """
         artifact = validated_data.pop('artifact')
-        if "relative_path" in self.fields and self.fields["relative_path"].write_only:
+        if "relative_path" not in self.fields or self.fields["relative_path"].write_only:
             relative_path = validated_data.pop('relative_path')
         else:
             relative_path = validated_data.get('relative_path')

{"golden_diff": "diff --git a/pulpcore/app/serializers/content.py b/pulpcore/app/serializers/content.py\n--- a/pulpcore/app/serializers/content.py\n+++ b/pulpcore/app/serializers/content.py\n@@ -57,7 +57,7 @@\n             validated_data (dict): Data to save to the database\n         \"\"\"\n         artifact = validated_data.pop('artifact')\n-        if \"relative_path\" in self.fields and self.fields[\"relative_path\"].write_only:\n+        if \"relative_path\" not in self.fields or self.fields[\"relative_path\"].write_only:\n             relative_path = validated_data.pop('relative_path')\n         else:\n             relative_path = validated_data.get('relative_path')\n", "issue": "[PR #5443/c7079c89 backport][3.54] Pin the pytest-redis requirement for unit tests\n**This is a backport of PR #5443 as merged into main (c7079c891b87ecd9073260db5baa35826803f635).**\n\n[noissue]\n", "before_files": [{"content": "import hashlib\nfrom gettext import gettext as _\n\nfrom django.db import transaction\nfrom rest_framework import serializers\nfrom rest_framework.validators import UniqueValidator\n\nfrom pulpcore.app import models\nfrom pulpcore.app.serializers import base, fields\n\nUNIQUE_ALGORITHMS = ['sha256', 'sha384', 'sha512']\n\n\nclass BaseContentSerializer(base.MasterModelSerializer):\n    _href = base.DetailIdentityField()\n\n    class Meta:\n        model = models.Content\n        fields = base.MasterModelSerializer.Meta.fields\n\n\nclass NoArtifactContentSerializer(BaseContentSerializer):\n\n    class Meta:\n        model = models.Content\n        fields = BaseContentSerializer.Meta.fields\n\n\nclass SingleArtifactContentSerializer(BaseContentSerializer):\n    artifact = fields.SingleContentArtifactField(\n        help_text=_(\"Artifact file representing the physical content\"),\n    )\n\n    relative_path = serializers.CharField(\n        help_text=_(\"Path where the artifact is located relative to distributions base_path\"),\n        validators=[fields.relative_path_validator],\n        write_only=True,\n    )\n\n    def __init__(self, *args, **kwargs):\n        \"\"\"\n        Initializer for SingleArtifactContentSerializer\n        \"\"\"\n        super().__init__(*args, **kwargs)\n\n        # If the content model has its own database field 'relative_path',\n        # we should not mark the field write_only\n        if hasattr(self.Meta.model, 'relative_path') and \"relative_path\" in self.fields:\n            self.fields[\"relative_path\"].write_only = False\n\n    @transaction.atomic\n    def create(self, validated_data):\n        \"\"\"\n        Create the content and associate it with its Artifact.\n\n        Args:\n            validated_data (dict): Data to save to the database\n        \"\"\"\n        artifact = validated_data.pop('artifact')\n        if \"relative_path\" in self.fields and self.fields[\"relative_path\"].write_only:\n            relative_path = validated_data.pop('relative_path')\n        else:\n            relative_path = validated_data.get('relative_path')\n        content = self.Meta.model.objects.create(**validated_data)\n        models.ContentArtifact.objects.create(\n            artifact=artifact,\n            content=content,\n            relative_path=relative_path,\n        )\n        return content\n\n    class Meta:\n        model = models.Content\n        fields = BaseContentSerializer.Meta.fields + ('artifact', 'relative_path')\n\n\nclass MultipleArtifactContentSerializer(BaseContentSerializer):\n    artifacts = fields.ContentArtifactsField(\n        help_text=_(\"A dict mapping relative paths inside the Content to the corresponding\"\n                    \"Artifact URLs. E.g.: {'relative/path': \"\n                    \"'/artifacts/1/'\"),\n    )\n\n    @transaction.atomic\n    def create(self, validated_data):\n        \"\"\"\n        Create the content and associate it with all its Artifacts.\n\n        Args:\n            validated_data (dict): Data to save to the database\n        \"\"\"\n        artifacts = validated_data.pop('artifacts')\n        content = self.Meta.model.objects.create(**validated_data)\n        for relative_path, artifact in artifacts.items():\n            models.ContentArtifact.objects.create(\n                artifact=artifact,\n                content=content,\n                relative_path=relative_path,\n            )\n        return content\n\n    class Meta:\n        model = models.Content\n        fields = BaseContentSerializer.Meta.fields + ('artifacts',)\n\n\nclass ContentChecksumSerializer(serializers.Serializer):\n    \"\"\"\n    Provide a serializer with artifact checksum fields for single artifact content.\n\n    If you use this serializer, it's recommended that you prefetch artifacts:\n\n        Content.objects.prefetch_related(\"_artifacts\").all()\n    \"\"\"\n\n    md5 = fields.ContentArtifactChecksumField(\n        help_text=_(\"The MD5 checksum if available.\"),\n        checksum='md5',\n    )\n\n    sha1 = fields.ContentArtifactChecksumField(\n        help_text=_(\"The SHA-1 checksum if available.\"),\n        checksum='sha1',\n    )\n\n    sha224 = fields.ContentArtifactChecksumField(\n        help_text=_(\"The SHA-224 checksum if available.\"),\n        checksum='sha224',\n    )\n\n    sha256 = fields.ContentArtifactChecksumField(\n        help_text=_(\"The SHA-256 checksum if available.\"),\n        checksum='sha256',\n    )\n\n    sha384 = fields.ContentArtifactChecksumField(\n        help_text=_(\"The SHA-384 checksum if available.\"),\n        checksum='sha384',\n    )\n\n    sha512 = fields.ContentArtifactChecksumField(\n        help_text=_(\"The SHA-512 checksum if available.\"),\n        checksum='sha512',\n    )\n\n    class Meta:\n        model = models.Content\n        fields = base.ModelSerializer.Meta.fields + ('md5', 'sha1', 'sha224', 'sha256', 'sha384',\n                                                     'sha512')\n\n\nclass ArtifactSerializer(base.ModelSerializer):\n    _href = base.IdentityField(\n        view_name='artifacts-detail',\n    )\n\n    file = serializers.FileField(\n        help_text=_(\"The stored file.\"),\n        allow_empty_file=True,\n        required=False\n    )\n\n    size = serializers.IntegerField(\n        help_text=_(\"The size of the file in bytes.\"),\n        required=False\n    )\n\n    md5 = serializers.CharField(\n        help_text=_(\"The MD5 checksum of the file if available.\"),\n        required=False,\n        allow_null=True,\n    )\n\n    sha1 = serializers.CharField(\n        help_text=_(\"The SHA-1 checksum of the file if available.\"),\n        required=False,\n        allow_null=True,\n    )\n\n    sha224 = serializers.CharField(\n        help_text=_(\"The SHA-224 checksum of the file if available.\"),\n        required=False,\n        allow_null=True,\n    )\n\n    sha256 = serializers.CharField(\n        help_text=_(\"The SHA-256 checksum of the file if available.\"),\n        required=False,\n        allow_null=True,\n    )\n\n    sha384 = serializers.CharField(\n        help_text=_(\"The SHA-384 checksum of the file if available.\"),\n        required=False,\n        allow_null=True,\n    )\n\n    sha512 = serializers.CharField(\n        help_text=_(\"The SHA-512 checksum of the file if available.\"),\n        required=False,\n        allow_null=True,\n    )\n\n    def validate(self, data):\n        \"\"\"\n        Validate file by size and by all checksums provided.\n\n        Args:\n            data (:class:`django.http.QueryDict`): QueryDict mapping Artifact model fields to their\n                values\n\n        Raises:\n            :class:`rest_framework.exceptions.ValidationError`: When the expected file size or any\n                of the checksums don't match their actual values.\n        \"\"\"\n        super().validate(data)\n\n        if 'size' in data:\n            if data['file'].size != int(data['size']):\n                raise serializers.ValidationError(_(\"The size did not match actual size of file.\"))\n        else:\n            data['size'] = data['file'].size\n\n        for algorithm in hashlib.algorithms_guaranteed:\n            if algorithm in models.Artifact.DIGEST_FIELDS:\n                digest = data['file'].hashers[algorithm].hexdigest()\n\n                if algorithm in data and digest != data[algorithm]:\n                    raise serializers.ValidationError(_(\"The %s checksum did not match.\")\n                                                      % algorithm)\n                else:\n                    data[algorithm] = digest\n                if algorithm in UNIQUE_ALGORITHMS:\n                    validator = UniqueValidator(models.Artifact.objects.all(),\n                                                message=_(\"{0} checksum must be \"\n                                                          \"unique.\").format(algorithm))\n                    validator.field_name = algorithm\n                    validator.instance = None\n                    validator(digest)\n        return data\n\n    class Meta:\n        model = models.Artifact\n        fields = base.ModelSerializer.Meta.fields + ('file', 'size', 'md5', 'sha1', 'sha224',\n                                                     'sha256', 'sha384', 'sha512')\n", "path": "pulpcore/app/serializers/content.py"}], "after_files": [{"content": "import hashlib\nfrom gettext import gettext as _\n\nfrom django.db import transaction\nfrom rest_framework import serializers\nfrom rest_framework.validators import UniqueValidator\n\nfrom pulpcore.app import models\nfrom pulpcore.app.serializers import base, fields\n\nUNIQUE_ALGORITHMS = ['sha256', 'sha384', 'sha512']\n\n\nclass BaseContentSerializer(base.MasterModelSerializer):\n    _href = base.DetailIdentityField()\n\n    class Meta:\n        model = models.Content\n        fields = base.MasterModelSerializer.Meta.fields\n\n\nclass NoArtifactContentSerializer(BaseContentSerializer):\n\n    class Meta:\n        model = models.Content\n        fields = BaseContentSerializer.Meta.fields\n\n\nclass SingleArtifactContentSerializer(BaseContentSerializer):\n    artifact = fields.SingleContentArtifactField(\n        help_text=_(\"Artifact file representing the physical content\"),\n    )\n\n    relative_path = serializers.CharField(\n        help_text=_(\"Path where the artifact is located relative to distributions base_path\"),\n        validators=[fields.relative_path_validator],\n        write_only=True,\n    )\n\n    def __init__(self, *args, **kwargs):\n        \"\"\"\n        Initializer for SingleArtifactContentSerializer\n        \"\"\"\n        super().__init__(*args, **kwargs)\n\n        # If the content model has its own database field 'relative_path',\n        # we should not mark the field write_only\n        if hasattr(self.Meta.model, 'relative_path') and \"relative_path\" in self.fields:\n            self.fields[\"relative_path\"].write_only = False\n\n    @transaction.atomic\n    def create(self, validated_data):\n        \"\"\"\n        Create the content and associate it with its Artifact.\n\n        Args:\n            validated_data (dict): Data to save to the database\n        \"\"\"\n        artifact = validated_data.pop('artifact')\n        if \"relative_path\" not in self.fields or self.fields[\"relative_path\"].write_only:\n            relative_path = validated_data.pop('relative_path')\n        else:\n            relative_path = validated_data.get('relative_path')\n        content = self.Meta.model.objects.create(**validated_data)\n        models.ContentArtifact.objects.create(\n            artifact=artifact,\n            content=content,\n            relative_path=relative_path,\n        )\n        return content\n\n    class Meta:\n        model = models.Content\n        fields = BaseContentSerializer.Meta.fields + ('artifact', 'relative_path')\n\n\nclass MultipleArtifactContentSerializer(BaseContentSerializer):\n    artifacts = fields.ContentArtifactsField(\n        help_text=_(\"A dict mapping relative paths inside the Content to the corresponding\"\n                    \"Artifact URLs. E.g.: {'relative/path': \"\n                    \"'/artifacts/1/'\"),\n    )\n\n    @transaction.atomic\n    def create(self, validated_data):\n        \"\"\"\n        Create the content and associate it with all its Artifacts.\n\n        Args:\n            validated_data (dict): Data to save to the database\n        \"\"\"\n        artifacts = validated_data.pop('artifacts')\n        content = self.Meta.model.objects.create(**validated_data)\n        for relative_path, artifact in artifacts.items():\n            models.ContentArtifact.objects.create(\n                artifact=artifact,\n                content=content,\n                relative_path=relative_path,\n            )\n        return content\n\n    class Meta:\n        model = models.Content\n        fields = BaseContentSerializer.Meta.fields + ('artifacts',)\n\n\nclass ContentChecksumSerializer(serializers.Serializer):\n    \"\"\"\n    Provide a serializer with artifact checksum fields for single artifact content.\n\n    If you use this serializer, it's recommended that you prefetch artifacts:\n\n        Content.objects.prefetch_related(\"_artifacts\").all()\n    \"\"\"\n\n    md5 = fields.ContentArtifactChecksumField(\n        help_text=_(\"The MD5 checksum if available.\"),\n        checksum='md5',\n    )\n\n    sha1 = fields.ContentArtifactChecksumField(\n        help_text=_(\"The SHA-1 checksum if available.\"),\n        checksum='sha1',\n    )\n\n    sha224 = fields.ContentArtifactChecksumField(\n        help_text=_(\"The SHA-224 checksum if available.\"),\n        checksum='sha224',\n    )\n\n    sha256 = fields.ContentArtifactChecksumField(\n        help_text=_(\"The SHA-256 checksum if available.\"),\n        checksum='sha256',\n    )\n\n    sha384 = fields.ContentArtifactChecksumField(\n        help_text=_(\"The SHA-384 checksum if available.\"),\n        checksum='sha384',\n    )\n\n    sha512 = fields.ContentArtifactChecksumField(\n        help_text=_(\"The SHA-512 checksum if available.\"),\n        checksum='sha512',\n    )\n\n    class Meta:\n        model = models.Content\n        fields = base.ModelSerializer.Meta.fields + ('md5', 'sha1', 'sha224', 'sha256', 'sha384',\n                                                     'sha512')\n\n\nclass ArtifactSerializer(base.ModelSerializer):\n    _href = base.IdentityField(\n        view_name='artifacts-detail',\n    )\n\n    file = serializers.FileField(\n        help_text=_(\"The stored file.\"),\n        allow_empty_file=True,\n        required=False\n    )\n\n    size = serializers.IntegerField(\n        help_text=_(\"The size of the file in bytes.\"),\n        required=False\n    )\n\n    md5 = serializers.CharField(\n        help_text=_(\"The MD5 checksum of the file if available.\"),\n        required=False,\n        allow_null=True,\n    )\n\n    sha1 = serializers.CharField(\n        help_text=_(\"The SHA-1 checksum of the file if available.\"),\n        required=False,\n        allow_null=True,\n    )\n\n    sha224 = serializers.CharField(\n        help_text=_(\"The SHA-224 checksum of the file if available.\"),\n        required=False,\n        allow_null=True,\n    )\n\n    sha256 = serializers.CharField(\n        help_text=_(\"The SHA-256 checksum of the file if available.\"),\n        required=False,\n        allow_null=True,\n    )\n\n    sha384 = serializers.CharField(\n        help_text=_(\"The SHA-384 checksum of the file if available.\"),\n        required=False,\n        allow_null=True,\n    )\n\n    sha512 = serializers.CharField(\n        help_text=_(\"The SHA-512 checksum of the file if available.\"),\n        required=False,\n        allow_null=True,\n    )\n\n    def validate(self, data):\n        \"\"\"\n        Validate file by size and by all checksums provided.\n\n        Args:\n            data (:class:`django.http.QueryDict`): QueryDict mapping Artifact model fields to their\n                values\n\n        Raises:\n            :class:`rest_framework.exceptions.ValidationError`: When the expected file size or any\n                of the checksums don't match their actual values.\n        \"\"\"\n        super().validate(data)\n\n        if 'size' in data:\n            if data['file'].size != int(data['size']):\n                raise serializers.ValidationError(_(\"The size did not match actual size of file.\"))\n        else:\n            data['size'] = data['file'].size\n\n        for algorithm in hashlib.algorithms_guaranteed:\n            if algorithm in models.Artifact.DIGEST_FIELDS:\n                digest = data['file'].hashers[algorithm].hexdigest()\n\n                if algorithm in data and digest != data[algorithm]:\n                    raise serializers.ValidationError(_(\"The %s checksum did not match.\")\n                                                      % algorithm)\n                else:\n                    data[algorithm] = digest\n                if algorithm in UNIQUE_ALGORITHMS:\n                    validator = UniqueValidator(models.Artifact.objects.all(),\n                                                message=_(\"{0} checksum must be \"\n                                                          \"unique.\").format(algorithm))\n                    validator.field_name = algorithm\n                    validator.instance = None\n                    validator(digest)\n        return data\n\n    class Meta:\n        model = models.Artifact\n        fields = base.ModelSerializer.Meta.fields + ('file', 'size', 'md5', 'sha1', 'sha224',\n                                                     'sha256', 'sha384', 'sha512')\n", "path": "pulpcore/app/serializers/content.py"}]}