Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show resume progress bar from the middle #361

Merged
merged 1 commit into from
May 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions gdown/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,11 @@ def download(
f = output

if tmp_file is not None and f.tell() != 0:
headers = {"Range": "bytes={}-".format(f.tell())}
start_size = f.tell()
headers = {"Range": "bytes={}-".format(start_size)}
res = sess.get(url, headers=headers, stream=True, verify=verify)
else:
start_size = 0

if not quiet:
print(log_messages.get("start", "Downloading...\n"), file=sys.stderr, end="")
Expand All @@ -337,9 +340,9 @@ def download(
try:
total = res.headers.get("Content-Length")
if total is not None:
total = int(total)
total = int(total) + start_size
if not quiet:
pbar = tqdm.tqdm(total=total, unit="B", unit_scale=True)
pbar = tqdm.tqdm(total=total, unit="B", initial=start_size, unit_scale=True)
t_start = time.time()
for chunk in res.iter_content(chunk_size=CHUNK_SIZE):
f.write(chunk)
Expand Down
Loading