Merge branch 'http-downloader-check-size' of git://github.com/andrewgaul/AntennaPod into andrewgaul-http-downloader-check-size

Conflicts:
	src/de/danoeh/antennapod/service/download/HttpDownloader.java
This commit is contained in:
daniel oeh 2013-08-17 15:54:04 +02:00
commit 46459b7c43
1 changed files with 11 additions and 2 deletions

View File

@ -6,7 +6,6 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
@ -61,7 +60,7 @@ public class HttpDownloader extends Downloader {
@Override
protected void download() {
DefaultHttpClient httpClient = null;
OutputStream out = null;
BufferedOutputStream out = null;
InputStream connection = null;
try {
HttpGet httpGet = new HttpGet(request.getSource());
@ -110,6 +109,16 @@ public class HttpDownloader extends Downloader {
if (cancelled) {
onCancelled();
} else {
out.flush();
if (request.getSize() != DownloadStatus.SIZE_UNKNOWN &&
request.getSoFar() != request.getSize()) {
onFail(DownloadError.ERROR_IO_ERROR,
"Download completed but size: " +
request.getSoFar() +
" does not equal expected size " +
request.getSize());
return;
}
onSuccess();
}
} else {