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

Feature: allow folders to be continued more usefully #288

Merged
merged 7 commits into from
May 12, 2024

Conversation

achadwick
Copy link
Contributor

  • The --continue option can now be used with folders.
  • When a download is being sent to a file, detect when the file to resume is complete (→ has its final name)
    • Avoids 0-byte ranged transfers (which still count against the shared folder's download limit!)
    • Speeds up --continue (resume mode) for partially transferred folders containing lots of files.
    • Especially useful when download allowances are very limited, e.g. Tor-proxied access, or very popular folders.
  • Now uses the conventional .part suffix for tempfiles, to make life nicer with Linux desktop thumbnailers.
  • Update command line arguments to match.

@achadwick
Copy link
Contributor Author

Apologies for the forced push. @wkentaro, any chance you could merge these now, or is there anything more you'd like to see? I've adapted the patch to your move of cli.py to __main__.py, and worked my new folder-mode --continue/resume handling in around the internal-only skip_download flag you introduced - Skip Download mode has priority.

Happy to review and update it to match your requirements.

@melMass
Copy link

melMass commented Mar 13, 2024

Yes please consider this, I run a fork just for this reason.
I just had to update my fork after an issue popped up

@ryukinix
Copy link

Just a random feedback: this feature is very useful. I'll install the fork one to have this.

achadwick and others added 6 commits May 12, 2024 15:10
Document existing gdown behaviour.
Allow folder mode to pass through the resume flag.
This still makes some unnecessary requests, however.

Duplicates wkentaro#275,
but also updates cli.py appropriately.
As an optimization, if the target file exists and gdown is in
resume mode, don’t even try to transfer the file again.
Obviously, this only makes sense when the atomic tempfile+rename
pattern is in use, meaning only when output is to a path.

This avoids unnecessary requests. Even a ranged GET with 0 bytes
left counts against Google’s download limits, and it’s just
faster. The --continue/resume flag is handled at both the file
level and the folder level, to avoid even more requests.

This noticeably improves performance and when mirroring folders
with lots of files, when attempting to resume the transfer at a
later time. It also allows better resumption of folder downloads
that got interrupted.

Update the function docs.

Update help text for --continue to cover the new behaviour.
This is nicer for a lot of Linux thumbnailers, which will now
avoid generating preview thumbnails for the partially transferred
files.
Now that gdown handles fully transferred files properly, by
ignoring them, the tempfile finder loop should only select files
ending with the right suffix (currently “(random).part”). This
avoids common situations where gdown finds the target file
itself, then tries to update it with a zero-byte partial transfer
in “--continue” mode.

Requiring a particular suffix also helps avoid a possible source
of file corruption when folders contain a lot of similarly named
files.
@wkentaro
Copy link
Owner

@achadwick Looks really useful. Thank you for the contribution!

@wkentaro wkentaro merged commit eeb6995 into wkentaro:main May 12, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature for pr
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants