title: iOS Resuming HLS download and deleting partially downloaded file
body: <p>I am implementing HLS streaming as per <a href="https://developer.apple.com/library/archive/documentation/AudioVideo/Conceptual/MediaPlaybackGuide/Contents/Resources/en.lproj/HTTPLiveStreaming/HTTPLiveStreaming.html" rel="nofollow noreferrer">Apple Docs</a> </p>
  
  <p>But the problem that I am facing is for resuming the download when the user kills the app. If a download is in progress and say its 50% done and the user kills the app or app is killed by the system due to any reason and when the app is alive again then the URL session delegate of <code>didCompleteWithError</code> is called</p>
  
  <pre><code>func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) {
  }
  </code></pre>
  
  <p>and here I dont have the partially downloaded file path or ability to resume the task.</p>
  
  <p>The only location for the downloaded file is called when the download is complete via the following delegate call</p>
  
  <pre><code>func urlSession(_ session: URLSession, assetDownloadTask: AVAssetDownloadTask, didFinishDownloadingTo location: URL) {
  }
  </code></pre>
  
  <p>Now doc says to use </p>
  
  <pre><code>downloadSession.getAllTasks { tasksArray in }
  </code></pre>
  
  <p>but unfortunately, it does not resume the download</p>
  
  <p>So my problem is</p>
  
  <ol>
  <li>How to resume the task from that downloaded state so that the entire download doesn't start all over again from 0% ? </li>
  <li>For the task that is not resumable or for a particular scenario where I don't want to resume it how can I delete the partially downloaded file ? How will I get the downloaded path (I don't want to search the entire documents directory)</li>
  </ol>