Skip to content

Commit

Permalink
Reset size and digests when retrying downloads
Browse files Browse the repository at this point in the history
fixes #2135
  • Loading branch information
mdellweg committed Jan 20, 2022
1 parent d23a1d6 commit e6f726d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES/2135.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed bug where retries of partially downloaded files failed digest and size validation.
4 changes: 3 additions & 1 deletion pulpcore/download/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def __init__(
self.semaphore = semaphore
else:
self.semaphore = asyncio.Semaphore() # This will always be acquired
self._digests = {n: pulp_hashlib.new(n) for n in Artifact.DIGEST_FIELDS}
self._digests = {}
self._size = 0
if self.expected_digests:
if not set(self.expected_digests).intersection(set(Artifact.DIGEST_FIELDS)):
Expand All @@ -124,6 +124,8 @@ def _ensure_writer_has_open_file(self):
if not self._writer:
self._writer = tempfile.NamedTemporaryFile(dir=os.getcwd(), delete=False)
self.path = self._writer.name
self._digests = {n: pulp_hashlib.new(n) for n in Artifact.DIGEST_FIELDS}
self._size = 0

async def handle_data(self, data):
"""
Expand Down

0 comments on commit e6f726d

Please sign in to comment.