Allow to resume downloads only if the destination file exists

This commit is contained in:
Gabriele M
2017-07-08 17:20:47 +02:00
parent b4f0abd97d
commit 1c212075f1

View File

@@ -132,6 +132,10 @@ class OkHttpDownloadClient implements DownloadClient {
final Request.Builder requestBuilder = new Request.Builder()
.url(mUrl)
.tag(DOWNLOAD_TAG);
if (!mDestination.exists()) {
mCallback.onFailure(mCancelled);
return;
}
long offset = mDestination.length();
requestBuilder.addHeader("Range", "bytes=" + offset + "-");
final Request request = requestBuilder.build();