epub-press icon indicating copy to clipboard operation
epub-press copied to clipboard

Epubs can only be downloaded once

Open SuzanaK opened this issue 3 years ago • 2 comments

Current Behavior

After downloading a book once with a GET request on /api/v1/books/<id>/download, a second request will return

{"errors":[{"status":"404","detail":"No book with that id was found."}]}

but /api/v1/books/<id>/status will still return

{"message":"Done!","progress":100}

Expected Behavior

I am not sure if it's a bug or a feature?

If it's a wanted feature that books will be deleted after the first download, I would expect that

  1. The download error message would state that the book existed but was already downloaded.
  2. The status return message would also state that the book was downloaded and cannot be downloaded again.
  3. The README and the API docs would inform about this behaviour.

Steps to reproduce

Run the steps from the Wiki and execute the GET request on /api/v1/books/<id>/download twice with the same ID.

System Information

Ubuntu 20.10, Docker 19.03.13

SuzanaK avatar Mar 31 '21 09:03 SuzanaK

Interesting! This makes sense. Some context as to what's going on:

  1. Books are deleted after ~5 minutes. Previously they just remained indefinitely, but that resulted in hard drives overflowing 😅. My thinking is that most people are generating a book and downloading it right away, so long term storage isn't really a use case.
  2. The status tracking is in a different section of the system and is basically just an object containing statuses. These statuses are cleared out on a different interval / there's a max number of statuses and old ones are cleared as space for new ones is needed.

I can see why this is confusing though. Ideally there would be some consistency between those two pieces. As for what users should expect for sequential requests - I don't think multiple requests is a use case I see a need for supporting. Things need to get cleared eventually. Perhaps in the status response it could say when the link would expire.

Shouldn't be a problem with most use cases though.

Hope that answers the question!

haroldtreen avatar Apr 10 '21 21:04 haroldtreen

Thanks for the explanation, now I understand what is going on. My use case for sequential downloads was downloading the .mobi and the .epub file but I admit that it's not a common use case probably.

Perhaps in the status response it could say when the link would expire.

That would definitely be helpful! A hint in the API docs would also be great.

SuzanaK avatar Apr 12 '21 16:04 SuzanaK