M-rcus / yiff-dl

Downloads files from creators on Yiff
https://m-rcus.github.io/yiff-dl/
MIT License
23 stars 3 forks source link

Improve handling of existing and broken files #9

Closed M-rcus closed 3 years ago

M-rcus commented 4 years ago

Some files error out mid-download, but are still partially written to disk. yiff-dl currently only checks if the file exists and not if it's a valid file.

An easy way of making sure the file is valid is by comparing the filesize (bytes) and comparing it with the Content-Length HTTP header. From there we have a few options:

  1. Yiff.party sends the Accept-Ranges: bytes header, so we can specify Range header and continue downloading from where we left off.
    • We'd essentially get the current 'length' (size in bytes) of the file and specify Range: 12355- which should give us the rest of the file.
  2. Start downloading it from the beginning.

The first option has a few benefits:

The second option allows us to make sure the file is downloaded correctly. I haven't experienced it myself, but assuming files can actually be corrupted even if "fully" downloaded, then the second option would be best.
I suspect that an issue like that would be very rare and it's just as easy to just manually remove the file and start yiff-dl again.

M-rcus commented 3 years ago

Closing due to the project being archived: https://github.com/M-rcus/yiff-dl#archived