diff options
author | ByteHamster <ByteHamster@users.noreply.github.com> | 2023-12-29 19:25:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-29 19:25:39 +0100 |
commit | 9db26b7bab8a8b8cf5a1c655f082d46b81a97f95 (patch) | |
tree | 0158cf91698d2d5efeadceb6f09ef0924c29eeaa /model/src | |
parent | 7508e15ab1a102e3fdc258cf829a622d08baf2e8 (diff) | |
download | AntennaPod-9db26b7bab8a8b8cf5a1c655f082d46b81a97f95.zip |
Remove unnecessary autodownload code (#6832)
This should not change any behavior.
The retry count and timing are managed by WorkManager, so this code is irrelevant.
Diffstat (limited to 'model/src')
-rw-r--r-- | model/src/main/java/de/danoeh/antennapod/model/feed/FeedItem.java | 52 |
1 files changed, 6 insertions, 46 deletions
diff --git a/model/src/main/java/de/danoeh/antennapod/model/feed/FeedItem.java b/model/src/main/java/de/danoeh/antennapod/model/feed/FeedItem.java index a8570ea4e..be0760bdb 100644 --- a/model/src/main/java/de/danoeh/antennapod/model/feed/FeedItem.java +++ b/model/src/main/java/de/danoeh/antennapod/model/feed/FeedItem.java @@ -11,7 +11,6 @@ import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set; -import java.util.concurrent.TimeUnit; /** * Item (episode) within a feed. @@ -65,7 +64,7 @@ public class FeedItem extends FeedComponent implements Serializable { private transient List<Chapter> chapters; private String imageUrl; - private long autoDownload = 1; + private boolean autoDownloadEnabled = true; /** * Any tags assigned to this item @@ -82,7 +81,7 @@ public class FeedItem extends FeedComponent implements Serializable { * */ public FeedItem(long id, String title, String link, Date pubDate, String paymentLink, long feedId, boolean hasChapters, String imageUrl, int state, - String itemIdentifier, long autoDownload, String podcastIndexChapterUrl) { + String itemIdentifier, boolean autoDownloadEnabled, String podcastIndexChapterUrl) { this.id = id; this.title = title; this.link = link; @@ -93,7 +92,7 @@ public class FeedItem extends FeedComponent implements Serializable { this.imageUrl = imageUrl; this.state = state; this.itemIdentifier = itemIdentifier; - this.autoDownload = autoDownload; + this.autoDownloadEnabled = autoDownloadEnabled; this.podcastIndexChapterUrl = podcastIndexChapterUrl; } @@ -361,50 +360,11 @@ public class FeedItem extends FeedComponent implements Serializable { } public void disableAutoDownload() { - this.autoDownload = 0; + this.autoDownloadEnabled = false; } - public long getAutoDownloadAttemptsAndTime() { - return autoDownload; - } - - public int getFailedAutoDownloadAttempts() { - // 0: auto download disabled - // 1: auto download enabled (default) - // > 1: auto download enabled, timestamp of last failed attempt, last digit denotes number of failed attempts - if (autoDownload <= 1) { - return 0; - } - int failedAttempts = (int)(autoDownload % 10); - if (failedAttempts == 0) { - failedAttempts = 10; - } - return failedAttempts; - } - - public void increaseFailedAutoDownloadAttempts(long now) { - if (autoDownload == 0) { - return; // Don't re-enable - } - int failedAttempts = getFailedAutoDownloadAttempts() + 1; - if (failedAttempts >= 5) { - disableAutoDownload(); // giving up - } else { - autoDownload = (now / 10) * 10 + failedAttempts; - } - } - - public boolean isAutoDownloadable(long now) { - if (media == null || media.isDownloaded() || autoDownload == 0) { - return false; - } - if (autoDownload == 1) { - return true; // Never failed - } - int failedAttempts = getFailedAutoDownloadAttempts(); - long waitingTime = TimeUnit.HOURS.toMillis((long) Math.pow(2, failedAttempts - 1)); - long lastAttempt = (autoDownload / 10) * 10; - return now >= (lastAttempt + waitingTime); + public boolean isAutoDownloadEnabled() { + return this.autoDownloadEnabled; } public boolean isDownloaded() { |