mike-ferenduros / ChunkyTNG-issues

Issues-only repo for ChunkyTNG project
3 stars 0 forks source link

Background downloads #52

Open mike-ferenduros opened 5 years ago

mike-ferenduros commented 5 years ago

Currently we just keep the app alive so long as there are transfers going, but iOS will only allow 10m or so of this before killing us. Background transfers have no such limitations but they have other issues:

  1. The app still needs to unpack the downloaded files, which probably can't happen in the background.
  2. They don't work with streaming.

Hence:

  1. Tapping the download button starts the download in background mode
  2. Opening a comic starts it streaming
  3. Opening a comic that's already downloading in background mode asks if you want to restart the download as a stream
  4. If we run out of background time with a streaming download active, we cancel it so it'll get retried in background mode.
  5. When a background download completes, the file is stashed with the comic and the queue is pumped. If the app is in the foreground, the file is unpacked, else it's left in place until the app next enters the foreground.