Skip to content

Commit

Permalink
reg: continue downloads was broken after 3114920
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Apr 17, 2024
1 parent 4d79f0f commit 4aae927
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 9 additions & 1 deletion dcoraid/download/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,15 @@ def task_download_resource(self):
url = self.get_resource_url()
headers = copy.deepcopy(self.api.headers)
if self.path_temp.exists():
# resume previous download
# Resume a previous download.
# We have to update the hash of the current file with
# the data that has already been uploaded.
if (self.sha256sum_dl is None
# We do not verify SHA256 for condensed
and not self.condensed):
with self.path_temp.open("rb") as fd:
while chunk := fd.read(1024**2):
hasher.update(chunk)
bytes_present = self.path_temp.stat().st_size
headers["Range"] = f"bytes={bytes_present}-"
with requests.get(url,
Expand Down
1 change: 1 addition & 0 deletions tests/test_download_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def test_download_resume():
download_path=td)
dj2.task_download_resource()
dj2.task_verify_resource()
assert not dj2.traceback
assert dj2.start_time is not None
assert dj2.end_time is not None
assert dj2.path.exists()
Expand Down

0 comments on commit 4aae927

Please sign in to comment.