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");
|
||||
while (!cancelled
|
||||
&& (count = connection.read(buffer)) != -1) {
|
||||
out.write(buffer, 0, count);
|
||||
request.setSoFar(request.getSoFar() + count);
|
||||
request.setProgressPercent((int) (((double) request
|
||||
.getSoFar() / (double) request
|
||||
.getSize()) * 100));
|
||||
try {
|
||||
while (!cancelled
|
||||
&& (count = connection.read(buffer)) != -1) {
|
||||
out.write(buffer, 0, count);
|
||||
request.setSoFar(request.getSoFar() + count);
|
||||
request.setProgressPercent((int) (((double) request
|
||||
.getSoFar() / (double) request
|
||||
.getSize()) * 100));
|
||||
}
|
||||
} catch(IOException e) {
|
||||
Log.e(TAG, Log.getStackTraceString(e));
|
||||
}
|
||||
if (cancelled) {
|
||||
onCancelled();
|
||||
|
@ -210,6 +214,9 @@ public class HttpDownloader extends Downloader {
|
|||
request.getSize()
|
||||
);
|
||||
return;
|
||||
} else if(request.getSoFar() == 0){
|
||||
onFail(DownloadError.ERROR_IO_ERROR, "Download completed, but nothing was read");
|
||||
return;
|
||||
}
|
||||
onSuccess();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue