Fixes "gzip finished without exhausting source" error
This commit is contained in:
parent
bb3f7255a9
commit
6a83057e28
|
@ -188,13 +188,17 @@ public class HttpDownloader extends Downloader {
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.d(TAG, "Starting download");
|
Log.d(TAG, "Starting download");
|
||||||
while (!cancelled
|
try {
|
||||||
&& (count = connection.read(buffer)) != -1) {
|
while (!cancelled
|
||||||
out.write(buffer, 0, count);
|
&& (count = connection.read(buffer)) != -1) {
|
||||||
request.setSoFar(request.getSoFar() + count);
|
out.write(buffer, 0, count);
|
||||||
request.setProgressPercent((int) (((double) request
|
request.setSoFar(request.getSoFar() + count);
|
||||||
.getSoFar() / (double) request
|
request.setProgressPercent((int) (((double) request
|
||||||
.getSize()) * 100));
|
.getSoFar() / (double) request
|
||||||
|
.getSize()) * 100));
|
||||||
|
}
|
||||||
|
} catch(IOException e) {
|
||||||
|
Log.e(TAG, Log.getStackTraceString(e));
|
||||||
}
|
}
|
||||||
if (cancelled) {
|
if (cancelled) {
|
||||||
onCancelled();
|
onCancelled();
|
||||||
|
@ -210,6 +214,9 @@ public class HttpDownloader extends Downloader {
|
||||||
request.getSize()
|
request.getSize()
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
|
} else if(request.getSoFar() == 0){
|
||||||
|
onFail(DownloadError.ERROR_IO_ERROR, "Download completed, but nothing was read");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
onSuccess();
|
onSuccess();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue