From 084b9c231744a5657a620087b4b560db38b66ab8 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Sun, 24 Mar 2024 17:57:00 +0100 Subject: Store last refresh attempt for feeds (#7022) --- .../antennapod/storage/database/PodDBAdapter.java | 30 ++++++++++++++-------- .../storage/database/mapper/FeedCursorMapper.java | 4 +-- 2 files changed, 22 insertions(+), 12 deletions(-) (limited to 'storage/database') diff --git a/storage/database/src/main/java/de/danoeh/antennapod/storage/database/PodDBAdapter.java b/storage/database/src/main/java/de/danoeh/antennapod/storage/database/PodDBAdapter.java index a169c8fda..261a9dd45 100644 --- a/storage/database/src/main/java/de/danoeh/antennapod/storage/database/PodDBAdapter.java +++ b/storage/database/src/main/java/de/danoeh/antennapod/storage/database/PodDBAdapter.java @@ -77,6 +77,7 @@ public class PodDBAdapter { public static final String KEY_FEED = "feed"; public static final String KEY_MEDIA = "media"; public static final String KEY_DOWNLOADED = "downloaded"; + public static final String KEY_LAST_REFRESH_ATTEMPT = "downloaded"; public static final String KEY_LASTUPDATE = "last_update"; public static final String KEY_FEEDFILE = "feedfile"; public static final String KEY_REASON = "reason"; @@ -135,14 +136,22 @@ public class PodDBAdapter { private static final String TABLE_PRIMARY_KEY = KEY_ID + " INTEGER PRIMARY KEY AUTOINCREMENT ,"; - private static final String CREATE_TABLE_FEEDS = "CREATE TABLE " - + TABLE_NAME_FEEDS + " (" + TABLE_PRIMARY_KEY + KEY_TITLE - + " TEXT," + KEY_CUSTOM_TITLE + " TEXT," + KEY_FILE_URL + " TEXT," + KEY_DOWNLOAD_URL + " TEXT," - + KEY_DOWNLOADED + " INTEGER," + KEY_LINK + " TEXT," - + KEY_DESCRIPTION + " TEXT," + KEY_PAYMENT_LINK + " TEXT," - + KEY_LASTUPDATE + " TEXT," + KEY_LANGUAGE + " TEXT," + KEY_AUTHOR - + " TEXT," + KEY_IMAGE_URL + " TEXT," + KEY_TYPE + " TEXT," - + KEY_FEED_IDENTIFIER + " TEXT," + KEY_AUTO_DOWNLOAD_ENABLED + " INTEGER DEFAULT 1," + private static final String CREATE_TABLE_FEEDS = "CREATE TABLE " + TABLE_NAME_FEEDS + " (" + + TABLE_PRIMARY_KEY + KEY_TITLE + " TEXT," + + KEY_CUSTOM_TITLE + " TEXT," + + KEY_FILE_URL + " TEXT," + + KEY_DOWNLOAD_URL + " TEXT," + + KEY_LAST_REFRESH_ATTEMPT + " INTEGER," + + KEY_LINK + " TEXT," + + KEY_DESCRIPTION + " TEXT," + + KEY_PAYMENT_LINK + " TEXT," + + KEY_LASTUPDATE + " TEXT," + + KEY_LANGUAGE + " TEXT," + + KEY_AUTHOR + " TEXT," + + KEY_IMAGE_URL + " TEXT," + + KEY_TYPE + " TEXT," + + KEY_FEED_IDENTIFIER + " TEXT," + + KEY_AUTO_DOWNLOAD_ENABLED + " INTEGER DEFAULT 1," + KEY_USERNAME + " TEXT," + KEY_PASSWORD + " TEXT," + KEY_INCLUDE_FILTER + " TEXT DEFAULT ''," @@ -284,7 +293,7 @@ public class PodDBAdapter { + TABLE_NAME_FEEDS + "." + KEY_CUSTOM_TITLE + ", " + TABLE_NAME_FEEDS + "." + KEY_FILE_URL + ", " + TABLE_NAME_FEEDS + "." + KEY_DOWNLOAD_URL + ", " - + TABLE_NAME_FEEDS + "." + KEY_DOWNLOADED + ", " + + TABLE_NAME_FEEDS + "." + KEY_LAST_REFRESH_ATTEMPT + ", " + TABLE_NAME_FEEDS + "." + KEY_LINK + ", " + TABLE_NAME_FEEDS + "." + KEY_DESCRIPTION + ", " + TABLE_NAME_FEEDS + "." + KEY_PAYMENT_LINK + ", " @@ -418,7 +427,7 @@ public class PodDBAdapter { values.put(KEY_FILE_URL, feed.getLocalFileUrl()); values.put(KEY_DOWNLOAD_URL, feed.getDownloadUrl()); - values.put(KEY_DOWNLOADED, feed.isDownloaded()); + values.put(KEY_LAST_REFRESH_ATTEMPT, feed.getLastRefreshAttempt()); values.put(KEY_LASTUPDATE, feed.getLastModified()); values.put(KEY_TYPE, feed.getType()); values.put(KEY_FEED_IDENTIFIER, feed.getFeedIdentifier()); @@ -748,6 +757,7 @@ public class PodDBAdapter { public void setFeedLastUpdateFailed(long feedId, boolean failed) { final String sql = "UPDATE " + TABLE_NAME_FEEDS + " SET " + KEY_LAST_UPDATE_FAILED + "=" + (failed ? "1" : "0") + + "," + KEY_LAST_REFRESH_ATTEMPT + "=" + System.currentTimeMillis() + " WHERE " + KEY_ID + "=" + feedId; db.execSQL(sql); } diff --git a/storage/database/src/main/java/de/danoeh/antennapod/storage/database/mapper/FeedCursorMapper.java b/storage/database/src/main/java/de/danoeh/antennapod/storage/database/mapper/FeedCursorMapper.java index bb5ea4df6..f7be7009f 100644 --- a/storage/database/src/main/java/de/danoeh/antennapod/storage/database/mapper/FeedCursorMapper.java +++ b/storage/database/src/main/java/de/danoeh/antennapod/storage/database/mapper/FeedCursorMapper.java @@ -32,7 +32,7 @@ public abstract class FeedCursorMapper { int indexFeedIdentifier = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_FEED_IDENTIFIER); int indexFileUrl = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_FILE_URL); int indexDownloadUrl = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_DOWNLOAD_URL); - int indexDownloaded = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_DOWNLOADED); + int indexLastRefreshed = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_LAST_REFRESH_ATTEMPT); int indexIsPaged = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_IS_PAGED); int indexNextPageLink = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_NEXT_PAGE_LINK); int indexHide = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_HIDE); @@ -55,7 +55,7 @@ public abstract class FeedCursorMapper { cursor.getString(indexImageUrl), cursor.getString(indexFileUrl), cursor.getString(indexDownloadUrl), - cursor.getInt(indexDownloaded) > 0, + cursor.getLong(indexLastRefreshed), cursor.getInt(indexIsPaged) > 0, cursor.getString(indexNextPageLink), cursor.getString(indexHide), -- cgit v1.2.3