From 9cc4a5a6caf59052de79941548c7ee5d9a031a06 Mon Sep 17 00:00:00 2001 From: Martin Fietz Date: Sun, 17 Jan 2016 19:40:00 +0100 Subject: [PATCH 1/2] Remove logging --- .../main/java/de/danoeh/antennapod/core/storage/DBWriter.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DBWriter.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DBWriter.java index d1d6bd750..e728abc3b 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/DBWriter.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DBWriter.java @@ -993,7 +993,6 @@ public class DBWriter { public static Future saveFeedItemAutoDownloadFailed(final FeedItem feedItem) { return dbExec.submit(() -> { int failedAttempts = feedItem.getFailedAutoDownloadAttempts() + 1; - Log.d(TAG, "failedAttempts: " + failedAttempts); long autoDownload; if(!feedItem.getAutoDownload() || failedAttempts >= 10) { autoDownload = 0; // giving up, disable auto download @@ -1001,8 +1000,6 @@ public class DBWriter { } else { long now = System.currentTimeMillis(); autoDownload = (now / 10) * 10 + failedAttempts; - Log.d(TAG, "now: " + now); - Log.d(TAG, "autoDownload: " + autoDownload); } final PodDBAdapter adapter = PodDBAdapter.getInstance(); adapter.open(); From 6ec174e0fbda3ebec087af7ca4773cdf39e68f98 Mon Sep 17 00:00:00 2001 From: Martin Fietz Date: Sun, 17 Jan 2016 19:41:02 +0100 Subject: [PATCH 2/2] Exponential back-off if storage is full --- .../antennapod/core/service/download/DownloadService.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java index c3afff276..efd2a5b06 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java @@ -204,8 +204,10 @@ public class DownloadService extends Service { return; } FeedItem item = media.getItem(); - if (status.getReason() == DownloadError.ERROR_HTTP_DATA_ERROR && - Integer.valueOf(status.getReasonDetailed()) == HttpURLConnection.HTTP_NOT_FOUND) { + boolean httpNotFound = status.getReason() == DownloadError.ERROR_HTTP_DATA_ERROR + && String.valueOf(HttpURLConnection.HTTP_NOT_FOUND).equals(status.getReasonDetailed()); + boolean notEnoughSpace = status.getReason() == DownloadError.ERROR_NOT_ENOUGH_SPACE; + if (httpNotFound || notEnoughSpace) { DBWriter.saveFeedItemAutoDownloadFailed(item).get(); } // to make lists reload the failed item, we fake an item update