From e99c7931f75b9b30bf411ab87b76ee093358f5d9 Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Sun, 30 Jun 2013 22:02:59 -0700 Subject: [PATCH] Check file size after download This commit may address symptoms seen in #187 and #197 where AntennaPod did not flag incomplete downloads as failed. --- .../antennapod/service/download/HttpDownloader.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/de/danoeh/antennapod/service/download/HttpDownloader.java b/src/de/danoeh/antennapod/service/download/HttpDownloader.java index 0cb89368d..7e0279d10 100644 --- a/src/de/danoeh/antennapod/service/download/HttpDownloader.java +++ b/src/de/danoeh/antennapod/service/download/HttpDownloader.java @@ -114,6 +114,15 @@ public class HttpDownloader extends Downloader { onCancelled(); } else { out.flush(); + if (status.getSize() != DownloadStatus.SIZE_UNKNOWN && + status.getSoFar() != status.getSize()) { + onFail(DownloadError.ERROR_IO_ERROR, + "Download completed but size: " + + status.getSoFar() + + " does not equal expected size " + + status.getSize()); + return; + } onSuccess(); } } else {