We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[noissue]: Update django-lifecycle requirement from <=1.1.2,>=1.0 to >=1.0,<=1.2.0
Updates the requirements on [django-lifecycle](https://github.com/rsinger86/django-lifecycle) to permit the latest version.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/rsinger86/django-lifecycle/releases">django-lifecycle's releases</a>.</em></p>
<blockquote>
<h2>1.2.0</h2>
<h2>What's Changed</h2>
<ul>
<li>Fix <code>has_changed</code> and <code>changed_to</code> when working with mutable data (i.e.: <code>dict</code>s) by <a href="https://github.com/AlaaNour94"><code>@​AlaaNour94</code></a> in <a href="https://redirect.github.com/rsinger86/django-lifecycle/pull/151">rsinger86/django-lifecycle#151</a></li>
<li>Hook condition can be now built using some predefined conditions and/or with custom ones by <a href="https://github.com/EnriqueSoria"><code>@​EnriqueSoria</code></a> in <a href="https://redirect.github.com/rsinger86/django-lifecycle/pull/150">rsinger86/django-lifecycle#150</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/AlaaNour94"><code>@​AlaaNour94</code></a> made their first contribution in <a href="https://redirect.github.com/rsinger86/django-lifecycle/pull/151">rsinger86/django-lifecycle#151</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a href="https://github.com/rsinger86/django-lifecycle/compare/1.1.2...1.2.0">https://github.com/rsinger86/django-lifecycle/compare/1.1.2...1.2.0</a></p>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/rsinger86/django-lifecycle/blob/master/CHANGELOG.md">django-lifecycle's changelog</a>.</em></p>
<blockquote>
<h1>1.2.0 (February 2024)</h1>
<ul>
<li>Hook condition can be now built using some predefined conditions and/or with custom ones.</li>
<li>Fix <code>has_changed</code> and <code>changed_to</code> when working with mutable data (i.e.: <code>dict</code>s). Thanks <a href="https://github.com/AlaaNour94"><code>@​AlaaNour94</code></a></li>
</ul>
<h1>1.1.2 (November 2023)</h1>
<ul>
<li>Fix: Hooks were failing if some watched field (those in <code>when=&quot;&quot;</code> or <code>when_any=[...]</code>) was a <code>GenericForeignKey</code></li>
</ul>
<h2>1.1.1 (November 2023)</h2>
<ul>
<li>Fix: Include missing <code>django_lifecycle_checks</code> into python package</li>
</ul>
<h2>1.1.0 (November 2023)</h2>
<ul>
<li>Drop support for Django &lt; 2.2.</li>
<li>Confirm support for Django 5.0. Thanks <a href="https://github.com/adamchainz"><code>@​adamchainz</code></a>!</li>
<li>Remove urlman from required packages. Thanks <a href="https://github.com/DmytroLitvinov"><code>@​DmytroLitvinov</code></a>!</li>
<li>Add an optional Django check to avoid errors by not inheriting from <code>LifecycleModelMixin</code> (or <code>LifecycleModel</code>)</li>
</ul>
<h2>1.0.2 (September 2023)</h2>
<ul>
<li>Correct package info to note that Django 4.0, 4.1, and 4.2 are supported.</li>
</ul>
<h2>1.0.1 (August 2023)</h2>
<ul>
<li>Initial state gets reset using <code>transaction.on_commit()</code>, fixing the <code>has_changed()</code> and <code>initial_value()</code> methods for on_commit hooks. Thanks <a href="https://github.com/alb3rto269"><code>@​alb3rto269</code></a>!</li>
</ul>
<h2>1.0.0 (May 2022)</h2>
<ul>
<li>Drops Python 3.6 support</li>
<li>Adds <code>priority</code> hook kwarg to control the order in which hooked methods fire. Thanks <a href="https://github.com/EnriqueSoria"><code>@​EnriqueSoria</code></a>!</li>
<li>Internal cleanup/refactoring. Thanks <a href="https://github.com/EnriqueSoria"><code>@​EnriqueSoria</code></a>!</li>
</ul>
<h2>0.9.6 (February 2022)</h2>
<ul>
<li>Adds missing <code>packaging</code> to <code>install_requires</code>. Thanks <a href="https://github.com/mikedep333"><code>@​mikedep333</code></a>!</li>
</ul>
<h2>0.9.5 (February 2022)</h2>
<ul>
<li>Makes the <code>has_changed</code>, <code>changes_to</code> conditions depend on whether the field in question was included in the SQL update/insert statement by checking
the <code>update_fields</code> argument passed to save.</li>
</ul>
<h2>0.9.4 (February 2022)</h2>
<ul>
<li>Adds optional <a href="https://github.com/hook"><code>@​hook</code></a> <code>on_commit</code> argument for executing hooks when the database transaction is committed. Thanks <a href="https://github.com/amcclosky"><code>@​amcclosky</code></a>!</li>
</ul>
<h2>0.9.3 (October 2021)</h2>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/rsinger86/django-lifecycle/commit/4cc4c0b8f5688f87e520a949350519619311815a"><code>4cc4c0b</code></a> chore: Prepare release 1.2.0</li>
<li><a href="https://github.com/rsinger86/django-lifecycle/commit/2ba92cec9b54ec89a29cf8870b81acb7c9c41f05"><code>2ba92ce</code></a> Merge pull request <a href="https://redirect.github.com/rsinger86/django-lifecycle/issues/150">#150</a> from rsinger86/feature/generalize-conditions</li>
<li><a href="https://github.com/rsinger86/django-lifecycle/commit/b8b6336e19de4a6e5eb8ad6e52dda0257e57ce94"><code>b8b6336</code></a> refactor: Rename conditions as suggested by <a href="https://github.com/mateocpdev"><code>@​mateocpdev</code></a></li>
<li><a href="https://github.com/rsinger86/django-lifecycle/commit/bca05776ee77cf61f16d4bc8fc145d76bc276b01"><code>bca0577</code></a> docs: Update docs to add new way to add conditions</li>
<li><a href="https://github.com/rsinger86/django-lifecycle/commit/f2c6b803c5d4445d00c07ffeec7e5c73f75d0f6a"><code>f2c6b80</code></a> feat: Allow to specify both condition or legacy params</li>
<li><a href="https://github.com/rsinger86/django-lifecycle/commit/b6581622b49a906b1aab6ae07c80a29d61e77d2d"><code>b658162</code></a> feat: Make conditions chainable through <code>&amp;</code> and <code>|</code></li>
<li><a href="https://github.com/rsinger86/django-lifecycle/commit/6eb62e7ee5dbb8b2bca9c4c3f8eb0086765c4267"><code>6eb62e7</code></a> feat: Replicate conditions tests from LifecycleMixinTests using new conditions</li>
<li><a href="https://github.com/rsinger86/django-lifecycle/commit/1b2ccb86a583f729ff916f473562814c30b446aa"><code>1b2ccb8</code></a> Merge remote-tracking branch 'origin/master' into feature/generalize-conditions</li>
<li><a href="https://github.com/rsinger86/django-lifecycle/commit/2d1b46672b7f660012dbff08a7fe29f6d10094ed"><code>2d1b466</code></a> Merge pull request <a href="https://redirect.github.com/rsinger86/django-lifecycle/issues/151">#151</a> from AlaaNour94/capture_mutable_fields_changes</li>
<li><a href="https://github.com/rsinger86/django-lifecycle/commit/98b69493e3914299d67a7eb8b05146bcfe20ea53"><code>98b6949</code></a> capture mutable fields changes</li>
<li>Additional commits viewable in <a href="https://github.com/rsinger86/django-lifecycle/compare/1.0.0...1.2.0">compare view</a></li>
</ul>
</details>
<br />


Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>

--- 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/models/upload.py`
Content:
```
1 import hashlib
2 import os
3 
4 from django.core.files.base import ContentFile
5 from django.db import models
6 
7 from pulpcore.app.models import Model
8 
9 
10 class Upload(Model):
11     """
12     A chunked upload. Stores chunks until used to create an artifact, etc.
13 
14     Fields:
15 
16         file (models.FileField): The stored file.
17         size (models.BigIntegerField): The size of the file in bytes.
18         completed (models.DateTimeField): Time when the upload is committed
19     """
20 
21     file = models.FileField(null=False, max_length=255)
22     size = models.BigIntegerField()
23     completed = models.DateTimeField(null=True)
24 
25     def append(self, chunk, offset):
26         """
27         Append a chunk to an upload.
28 
29         Args:
30             chunk (File): Binary file to append to the upload file.
31             offset (int): First byte position to write chunk to.
32         """
33         if not self.file:
34             self.file.save(os.path.join('upload', str(self.pk)), ContentFile(''))
35 
36         with self.file.open(mode='r+b') as file:
37             file.seek(offset)
38             file.write(chunk.read())
39 
40         self.chunks.create(offset=offset, size=len(chunk))
41 
42     @property
43     def sha256(self, rehash=False):
44         if getattr(self, '_sha256', None) is None or rehash is True:
45             sha256 = hashlib.sha256()
46             with self.file.open(mode='rb') as file:
47                 for chunk in file.chunks():
48                     sha256.update(chunk)
49             self._sha256 = sha256.hexdigest()
50         return self._sha256
51 
52 
53 class UploadChunk(Model):
54     """
55     A chunk for an uploaded file.
56 
57     Fields:
58 
59         upload (models.ForeignKey): Upload this chunk belongs to.
60         offset (models.BigIntegerField): Start of the chunk in bytes.
61         size (models.BigIntegerField): Size of the chunk in bytes.
62     """
63 
64     upload = models.ForeignKey(Upload, on_delete=models.CASCADE, related_name='chunks')
65     offset = models.BigIntegerField()
66     size = models.BigIntegerField()
67
```
--- 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/models/upload.py b/pulpcore/app/models/upload.py
--- a/pulpcore/app/models/upload.py
+++ b/pulpcore/app/models/upload.py
@@ -49,6 +49,17 @@
             self._sha256 = sha256.hexdigest()
         return self._sha256
 
+    def delete(self, *args, **kwargs):
+        """
+        Deletes Upload model and the file associated with the model
+
+        Args:
+            args (list): list of positional arguments for Model.delete()
+            kwargs (dict): dictionary of keyword arguments to pass to Model.delete()
+        """
+        super().delete(*args, **kwargs)
+        self.file.delete(save=False)
+
 
 class UploadChunk(Model):
     """

{"golden_diff": "diff --git a/pulpcore/app/models/upload.py b/pulpcore/app/models/upload.py\n--- a/pulpcore/app/models/upload.py\n+++ b/pulpcore/app/models/upload.py\n@@ -49,6 +49,17 @@\n             self._sha256 = sha256.hexdigest()\n         return self._sha256\n \n+    def delete(self, *args, **kwargs):\n+        \"\"\"\n+        Deletes Upload model and the file associated with the model\n+\n+        Args:\n+            args (list): list of positional arguments for Model.delete()\n+            kwargs (dict): dictionary of keyword arguments to pass to Model.delete()\n+        \"\"\"\n+        super().delete(*args, **kwargs)\n+        self.file.delete(save=False)\n+\n \n class UploadChunk(Model):\n     \"\"\"\n", "issue": "[noissue]: Update django-lifecycle requirement from <=1.1.2,>=1.0 to >=1.0,<=1.2.0\nUpdates the requirements on [django-lifecycle](https://github.com/rsinger86/django-lifecycle) to permit the latest version.\n<details>\n<summary>Release notes</summary>\n<p><em>Sourced from <a href=\"https://github.com/rsinger86/django-lifecycle/releases\">django-lifecycle's releases</a>.</em></p>\n<blockquote>\n<h2>1.2.0</h2>\n<h2>What's Changed</h2>\n<ul>\n<li>Fix <code>has_changed</code> and <code>changed_to</code> when working with mutable data (i.e.: <code>dict</code>s) by <a href=\"https://github.com/AlaaNour94\"><code>@\u200bAlaaNour94</code></a> in <a href=\"https://redirect.github.com/rsinger86/django-lifecycle/pull/151\">rsinger86/django-lifecycle#151</a></li>\n<li>Hook condition can be now built using some predefined conditions and/or with custom ones by <a href=\"https://github.com/EnriqueSoria\"><code>@\u200bEnriqueSoria</code></a> in <a href=\"https://redirect.github.com/rsinger86/django-lifecycle/pull/150\">rsinger86/django-lifecycle#150</a></li>\n</ul>\n<h2>New Contributors</h2>\n<ul>\n<li><a href=\"https://github.com/AlaaNour94\"><code>@\u200bAlaaNour94</code></a> made their first contribution in <a href=\"https://redirect.github.com/rsinger86/django-lifecycle/pull/151\">rsinger86/django-lifecycle#151</a></li>\n</ul>\n<p><strong>Full Changelog</strong>: <a href=\"https://github.com/rsinger86/django-lifecycle/compare/1.1.2...1.2.0\">https://github.com/rsinger86/django-lifecycle/compare/1.1.2...1.2.0</a></p>\n</blockquote>\n</details>\n<details>\n<summary>Changelog</summary>\n<p><em>Sourced from <a href=\"https://github.com/rsinger86/django-lifecycle/blob/master/CHANGELOG.md\">django-lifecycle's changelog</a>.</em></p>\n<blockquote>\n<h1>1.2.0 (February 2024)</h1>\n<ul>\n<li>Hook condition can be now built using some predefined conditions and/or with custom ones.</li>\n<li>Fix <code>has_changed</code> and <code>changed_to</code> when working with mutable data (i.e.: <code>dict</code>s). Thanks <a href=\"https://github.com/AlaaNour94\"><code>@\u200bAlaaNour94</code></a></li>\n</ul>\n<h1>1.1.2 (November 2023)</h1>\n<ul>\n<li>Fix: Hooks were failing if some watched field (those in <code>when=&quot;&quot;</code> or <code>when_any=[...]</code>) was a <code>GenericForeignKey</code></li>\n</ul>\n<h2>1.1.1 (November 2023)</h2>\n<ul>\n<li>Fix: Include missing <code>django_lifecycle_checks</code> into python package</li>\n</ul>\n<h2>1.1.0 (November 2023)</h2>\n<ul>\n<li>Drop support for Django &lt; 2.2.</li>\n<li>Confirm support for Django 5.0. Thanks <a href=\"https://github.com/adamchainz\"><code>@\u200badamchainz</code></a>!</li>\n<li>Remove urlman from required packages. Thanks <a href=\"https://github.com/DmytroLitvinov\"><code>@\u200bDmytroLitvinov</code></a>!</li>\n<li>Add an optional Django check to avoid errors by not inheriting from <code>LifecycleModelMixin</code> (or <code>LifecycleModel</code>)</li>\n</ul>\n<h2>1.0.2 (September 2023)</h2>\n<ul>\n<li>Correct package info to note that Django 4.0, 4.1, and 4.2 are supported.</li>\n</ul>\n<h2>1.0.1 (August 2023)</h2>\n<ul>\n<li>Initial state gets reset using <code>transaction.on_commit()</code>, fixing the <code>has_changed()</code> and <code>initial_value()</code> methods for on_commit hooks. Thanks <a href=\"https://github.com/alb3rto269\"><code>@\u200balb3rto269</code></a>!</li>\n</ul>\n<h2>1.0.0 (May 2022)</h2>\n<ul>\n<li>Drops Python 3.6 support</li>\n<li>Adds <code>priority</code> hook kwarg to control the order in which hooked methods fire. Thanks <a href=\"https://github.com/EnriqueSoria\"><code>@\u200bEnriqueSoria</code></a>!</li>\n<li>Internal cleanup/refactoring. Thanks <a href=\"https://github.com/EnriqueSoria\"><code>@\u200bEnriqueSoria</code></a>!</li>\n</ul>\n<h2>0.9.6 (February 2022)</h2>\n<ul>\n<li>Adds missing <code>packaging</code> to <code>install_requires</code>. Thanks <a href=\"https://github.com/mikedep333\"><code>@\u200bmikedep333</code></a>!</li>\n</ul>\n<h2>0.9.5 (February 2022)</h2>\n<ul>\n<li>Makes the <code>has_changed</code>, <code>changes_to</code> conditions depend on whether the field in question was included in the SQL update/insert statement by checking\nthe <code>update_fields</code> argument passed to save.</li>\n</ul>\n<h2>0.9.4 (February 2022)</h2>\n<ul>\n<li>Adds optional <a href=\"https://github.com/hook\"><code>@\u200bhook</code></a> <code>on_commit</code> argument for executing hooks when the database transaction is committed. Thanks <a href=\"https://github.com/amcclosky\"><code>@\u200bamcclosky</code></a>!</li>\n</ul>\n<h2>0.9.3 (October 2021)</h2>\n<!-- raw HTML omitted -->\n</blockquote>\n<p>... (truncated)</p>\n</details>\n<details>\n<summary>Commits</summary>\n<ul>\n<li><a href=\"https://github.com/rsinger86/django-lifecycle/commit/4cc4c0b8f5688f87e520a949350519619311815a\"><code>4cc4c0b</code></a> chore: Prepare release 1.2.0</li>\n<li><a href=\"https://github.com/rsinger86/django-lifecycle/commit/2ba92cec9b54ec89a29cf8870b81acb7c9c41f05\"><code>2ba92ce</code></a> Merge pull request <a href=\"https://redirect.github.com/rsinger86/django-lifecycle/issues/150\">#150</a> from rsinger86/feature/generalize-conditions</li>\n<li><a href=\"https://github.com/rsinger86/django-lifecycle/commit/b8b6336e19de4a6e5eb8ad6e52dda0257e57ce94\"><code>b8b6336</code></a> refactor: Rename conditions as suggested by <a href=\"https://github.com/mateocpdev\"><code>@\u200bmateocpdev</code></a></li>\n<li><a href=\"https://github.com/rsinger86/django-lifecycle/commit/bca05776ee77cf61f16d4bc8fc145d76bc276b01\"><code>bca0577</code></a> docs: Update docs to add new way to add conditions</li>\n<li><a href=\"https://github.com/rsinger86/django-lifecycle/commit/f2c6b803c5d4445d00c07ffeec7e5c73f75d0f6a\"><code>f2c6b80</code></a> feat: Allow to specify both condition or legacy params</li>\n<li><a href=\"https://github.com/rsinger86/django-lifecycle/commit/b6581622b49a906b1aab6ae07c80a29d61e77d2d\"><code>b658162</code></a> feat: Make conditions chainable through <code>&amp;</code> and <code>|</code></li>\n<li><a href=\"https://github.com/rsinger86/django-lifecycle/commit/6eb62e7ee5dbb8b2bca9c4c3f8eb0086765c4267\"><code>6eb62e7</code></a> feat: Replicate conditions tests from LifecycleMixinTests using new conditions</li>\n<li><a href=\"https://github.com/rsinger86/django-lifecycle/commit/1b2ccb86a583f729ff916f473562814c30b446aa\"><code>1b2ccb8</code></a> Merge remote-tracking branch 'origin/master' into feature/generalize-conditions</li>\n<li><a href=\"https://github.com/rsinger86/django-lifecycle/commit/2d1b46672b7f660012dbff08a7fe29f6d10094ed\"><code>2d1b466</code></a> Merge pull request <a href=\"https://redirect.github.com/rsinger86/django-lifecycle/issues/151\">#151</a> from AlaaNour94/capture_mutable_fields_changes</li>\n<li><a href=\"https://github.com/rsinger86/django-lifecycle/commit/98b69493e3914299d67a7eb8b05146bcfe20ea53\"><code>98b6949</code></a> capture mutable fields changes</li>\n<li>Additional commits viewable in <a href=\"https://github.com/rsinger86/django-lifecycle/compare/1.0.0...1.2.0\">compare view</a></li>\n</ul>\n</details>\n<br />\n\n\nDependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.\n\n[//]: # (dependabot-automerge-start)\n[//]: # (dependabot-automerge-end)\n\n---\n\n<details>\n<summary>Dependabot commands and options</summary>\n<br />\n\nYou can trigger Dependabot actions by commenting on this PR:\n- `@dependabot rebase` will rebase this PR\n- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it\n- `@dependabot merge` will merge this PR after your CI passes on it\n- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it\n- `@dependabot cancel merge` will cancel a previously requested merge and block automerging\n- `@dependabot reopen` will reopen this PR if it is closed\n- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually\n- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency\n- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)\n- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)\n- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)\n\n\n</details>\n", "before_files": [{"content": "import hashlib\nimport os\n\nfrom django.core.files.base import ContentFile\nfrom django.db import models\n\nfrom pulpcore.app.models import Model\n\n\nclass Upload(Model):\n    \"\"\"\n    A chunked upload. Stores chunks until used to create an artifact, etc.\n\n    Fields:\n\n        file (models.FileField): The stored file.\n        size (models.BigIntegerField): The size of the file in bytes.\n        completed (models.DateTimeField): Time when the upload is committed\n    \"\"\"\n\n    file = models.FileField(null=False, max_length=255)\n    size = models.BigIntegerField()\n    completed = models.DateTimeField(null=True)\n\n    def append(self, chunk, offset):\n        \"\"\"\n        Append a chunk to an upload.\n\n        Args:\n            chunk (File): Binary file to append to the upload file.\n            offset (int): First byte position to write chunk to.\n        \"\"\"\n        if not self.file:\n            self.file.save(os.path.join('upload', str(self.pk)), ContentFile(''))\n\n        with self.file.open(mode='r+b') as file:\n            file.seek(offset)\n            file.write(chunk.read())\n\n        self.chunks.create(offset=offset, size=len(chunk))\n\n    @property\n    def sha256(self, rehash=False):\n        if getattr(self, '_sha256', None) is None or rehash is True:\n            sha256 = hashlib.sha256()\n            with self.file.open(mode='rb') as file:\n                for chunk in file.chunks():\n                    sha256.update(chunk)\n            self._sha256 = sha256.hexdigest()\n        return self._sha256\n\n\nclass UploadChunk(Model):\n    \"\"\"\n    A chunk for an uploaded file.\n\n    Fields:\n\n        upload (models.ForeignKey): Upload this chunk belongs to.\n        offset (models.BigIntegerField): Start of the chunk in bytes.\n        size (models.BigIntegerField): Size of the chunk in bytes.\n    \"\"\"\n\n    upload = models.ForeignKey(Upload, on_delete=models.CASCADE, related_name='chunks')\n    offset = models.BigIntegerField()\n    size = models.BigIntegerField()\n", "path": "pulpcore/app/models/upload.py"}], "after_files": [{"content": "import hashlib\nimport os\n\nfrom django.core.files.base import ContentFile\nfrom django.db import models\n\nfrom pulpcore.app.models import Model\n\n\nclass Upload(Model):\n    \"\"\"\n    A chunked upload. Stores chunks until used to create an artifact, etc.\n\n    Fields:\n\n        file (models.FileField): The stored file.\n        size (models.BigIntegerField): The size of the file in bytes.\n        completed (models.DateTimeField): Time when the upload is committed\n    \"\"\"\n\n    file = models.FileField(null=False, max_length=255)\n    size = models.BigIntegerField()\n    completed = models.DateTimeField(null=True)\n\n    def append(self, chunk, offset):\n        \"\"\"\n        Append a chunk to an upload.\n\n        Args:\n            chunk (File): Binary file to append to the upload file.\n            offset (int): First byte position to write chunk to.\n        \"\"\"\n        if not self.file:\n            self.file.save(os.path.join('upload', str(self.pk)), ContentFile(''))\n\n        with self.file.open(mode='r+b') as file:\n            file.seek(offset)\n            file.write(chunk.read())\n\n        self.chunks.create(offset=offset, size=len(chunk))\n\n    @property\n    def sha256(self, rehash=False):\n        if getattr(self, '_sha256', None) is None or rehash is True:\n            sha256 = hashlib.sha256()\n            with self.file.open(mode='rb') as file:\n                for chunk in file.chunks():\n                    sha256.update(chunk)\n            self._sha256 = sha256.hexdigest()\n        return self._sha256\n\n    def delete(self, *args, **kwargs):\n        \"\"\"\n        Deletes Upload model and the file associated with the model\n\n        Args:\n            args (list): list of positional arguments for Model.delete()\n            kwargs (dict): dictionary of keyword arguments to pass to Model.delete()\n        \"\"\"\n        super().delete(*args, **kwargs)\n        self.file.delete(save=False)\n\n\nclass UploadChunk(Model):\n    \"\"\"\n    A chunk for an uploaded file.\n\n    Fields:\n\n        upload (models.ForeignKey): Upload this chunk belongs to.\n        offset (models.BigIntegerField): Start of the chunk in bytes.\n        size (models.BigIntegerField): Size of the chunk in bytes.\n    \"\"\"\n\n    upload = models.ForeignKey(Upload, on_delete=models.CASCADE, related_name='chunks')\n    offset = models.BigIntegerField()\n    size = models.BigIntegerField()\n", "path": "pulpcore/app/models/upload.py"}]}