Skip to content

Downloading On The Fly files #750

Description

@AlanJAS

Trying download some items with "--on-the-fly" flag, it results in two problems:

  1. If the file exists in IA (for example, an .epub file is already created) the code tries to download again, and gives an error.
  2. If the file doesn't exists, IA not creates it.

I'm not sure about 2 behavior, but the documentation says "Some files on archive.org are generated on-the-fly as requested". Maybe it's a server side problem.

And for 1: if the file exists, is on the list "item_files" at item.py line 682. And in the line 691, the for loop added again without checking if the file are in the list.

Continue the search of the problem, the "get_file" function always create a File object type (from files.py). Where is used "OnTheFlyFile" class? (files.py:491)

When "download" is invoquen from files.py, at line 309 we have:

st = os.stat(file_path.encode('utf-8'))
if st.st_size != self.size and not (checksum or checksum_archive):
headers = {"Range": f"bytes={st.st_size}-"}

In "st" we have the size of the dowloaded file. In self.size we have the size of the actual file that is 0 (this is the file added in for loop). And because it's different, the header range it's wrong, given the 416 error of "Requested Range Not Satisfiable". The code is calling a range beginning in the end of it, that's its an error.

The problem could be solved in the for loop, adding only the files that not exists.

An example of item that have an EPUB file:

$ ia download goodytwoshoes00newyiala --on-the-fly
...
downloading goodytwoshoes00newyiala.epub: 100%...
....
error downloading file goodytwoshoes00newyiala/goodytwoshoes00newyiala.epub, exception raised: 416 Client Error: Requested Range Not Satisfiable for url:....
error downloading file goodytwoshoes00newyiala/goodytwoshoes00newyiala.mobi, exception raised: 404 Client Error: Not Found for url:...
error downloading file goodytwoshoes00newyiala/goodytwoshoes00newyiala_daisy.zip, exception raised: 416 Client Error: Requested Range Not Satisfiable for url:...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions