diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2013-08-28 19:41:00 +0200 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2013-08-28 19:41:00 +0200 |
commit | fb1d348e282c13fd9a78702af7cd1303c940252f (patch) | |
tree | 6807e9f9a053180270174849ea6e9b6612b739b1 /src/de/danoeh | |
parent | 307fda7ca91fdc22078b84fce738c01e5cdf094b (diff) | |
download | AntennaPod-fb1d348e282c13fd9a78702af7cd1303c940252f.zip |
Updated unit tests
Diffstat (limited to 'src/de/danoeh')
-rw-r--r-- | src/de/danoeh/antennapod/service/download/HttpDownloader.java | 10 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/storage/DBTasks.java | 8 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/de/danoeh/antennapod/service/download/HttpDownloader.java b/src/de/danoeh/antennapod/service/download/HttpDownloader.java index adf93e0f2..582fb9575 100644 --- a/src/de/danoeh/antennapod/service/download/HttpDownloader.java +++ b/src/de/danoeh/antennapod/service/download/HttpDownloader.java @@ -11,6 +11,7 @@ import java.net.SocketTimeoutException; import java.net.UnknownHostException; import org.apache.commons.io.IOUtils; +import org.apache.http.Header; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpGet; @@ -68,6 +69,11 @@ public class HttpDownloader extends Downloader { HttpResponse response = httpClient.execute(httpGet); HttpEntity httpEntity = response.getEntity(); int responseCode = response.getStatusLine().getStatusCode(); + Header contentEncodingHeader = response.getFirstHeader("Content-Encoding"); + + final boolean isGzip = contentEncodingHeader != null && + contentEncodingHeader.getValue().equalsIgnoreCase("gzip"); + if (AppConfig.DEBUG) Log.d(TAG, "Response code is " + responseCode); @@ -129,7 +135,9 @@ public class HttpDownloader extends Downloader { onCancelled(); } else { out.flush(); - if (request.getSize() != DownloadStatus.SIZE_UNKNOWN && + // check if size specified in the response header is the same as the size of the + // written file. This check cannot be made if compression was used + if (!isGzip && request.getSize() != DownloadStatus.SIZE_UNKNOWN && request.getSoFar() != request.getSize()) { onFail(DownloadError.ERROR_IO_ERROR, "Download completed but size: " + diff --git a/src/de/danoeh/antennapod/storage/DBTasks.java b/src/de/danoeh/antennapod/storage/DBTasks.java index 4ce1a0c96..741699bdf 100644 --- a/src/de/danoeh/antennapod/storage/DBTasks.java +++ b/src/de/danoeh/antennapod/storage/DBTasks.java @@ -441,7 +441,13 @@ public final class DBTasks { } for (FeedItem item : delete) { - DBWriter.deleteFeedMediaOfItem(context, item.getId()); + try { + DBWriter.deleteFeedMediaOfItem(context, item.getId()).get(); + } catch (InterruptedException e) { + e.printStackTrace(); + } catch (ExecutionException e) { + e.printStackTrace(); + } } int counter = delete.size(); |