Fixes "gzip finished without exhausting source" error

This commit is contained in:
Martin Fietz 2015-06-03 11:36:25 +02:00
parent bb3f7255a9
commit 6a83057e28
1 changed files with 14 additions and 7 deletions

View File

@ -188,6 +188,7 @@ public class HttpDownloader extends Downloader {
} }
Log.d(TAG, "Starting download"); Log.d(TAG, "Starting download");
try {
while (!cancelled while (!cancelled
&& (count = connection.read(buffer)) != -1) { && (count = connection.read(buffer)) != -1) {
out.write(buffer, 0, count); out.write(buffer, 0, count);
@ -196,6 +197,9 @@ public class HttpDownloader extends Downloader {
.getSoFar() / (double) request .getSoFar() / (double) request
.getSize()) * 100)); .getSize()) * 100));
} }
} catch(IOException e) {
Log.e(TAG, Log.getStackTraceString(e));
}
if (cancelled) { if (cancelled) {
onCancelled(); onCancelled();
} else { } else {
@ -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();
} }