Merge pull request #1567 from mfietz/issue/1296-dl-retry-loop-no-space

Avoid download retry loop when storage is full
This commit is contained in:
Tom Hennen 2016-01-23 10:04:28 -05:00
commit 932620e73c
2 changed files with 4 additions and 5 deletions

View File

@ -204,8 +204,10 @@ public class DownloadService extends Service {
return; return;
} }
FeedItem item = media.getItem(); FeedItem item = media.getItem();
if (status.getReason() == DownloadError.ERROR_HTTP_DATA_ERROR && boolean httpNotFound = status.getReason() == DownloadError.ERROR_HTTP_DATA_ERROR
Integer.valueOf(status.getReasonDetailed()) == HttpURLConnection.HTTP_NOT_FOUND) { && 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(); DBWriter.saveFeedItemAutoDownloadFailed(item).get();
} }
// to make lists reload the failed item, we fake an item update // to make lists reload the failed item, we fake an item update

View File

@ -993,7 +993,6 @@ public class DBWriter {
public static Future<?> saveFeedItemAutoDownloadFailed(final FeedItem feedItem) { public static Future<?> saveFeedItemAutoDownloadFailed(final FeedItem feedItem) {
return dbExec.submit(() -> { return dbExec.submit(() -> {
int failedAttempts = feedItem.getFailedAutoDownloadAttempts() + 1; int failedAttempts = feedItem.getFailedAutoDownloadAttempts() + 1;
Log.d(TAG, "failedAttempts: " + failedAttempts);
long autoDownload; long autoDownload;
if(!feedItem.getAutoDownload() || failedAttempts >= 10) { if(!feedItem.getAutoDownload() || failedAttempts >= 10) {
autoDownload = 0; // giving up, disable auto download autoDownload = 0; // giving up, disable auto download
@ -1001,8 +1000,6 @@ public class DBWriter {
} else { } else {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
autoDownload = (now / 10) * 10 + failedAttempts; autoDownload = (now / 10) * 10 + failedAttempts;
Log.d(TAG, "now: " + now);
Log.d(TAG, "autoDownload: " + autoDownload);
} }
final PodDBAdapter adapter = PodDBAdapter.getInstance(); final PodDBAdapter adapter = PodDBAdapter.getInstance();
adapter.open(); adapter.open();