Bugfix: Chapters were saved multiple times

This commit is contained in:
daniel oeh 2015-01-08 13:12:45 +01:00
parent 9ece3a7db4
commit 389e1accdd
2 changed files with 18 additions and 3 deletions

View File

@ -13,7 +13,7 @@ public class StorageCallbacksImpl implements StorageCallbacks {
@Override @Override
public int getDatabaseVersion() { public int getDatabaseVersion() {
return 13; return 14;
} }
@Override @Override
@ -105,9 +105,24 @@ public class StorageCallbacksImpl implements StorageCallbacks {
} }
if (oldVersion <= 12) { if (oldVersion <= 12) {
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEEDS db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEEDS
+ " ADD COLUMN " + PodDBAdapter.KEY_IS_PAGED + " INTEGER DEFAULT 0"); + " ADD COLUMN " + PodDBAdapter.KEY_IS_PAGED + " INTEGER DEFAULT 0");
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEEDS db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEEDS
+ " ADD COLUMN " + PodDBAdapter.KEY_NEXT_PAGE_LINK + " TEXT"); + " ADD COLUMN " + PodDBAdapter.KEY_NEXT_PAGE_LINK + " TEXT");
} }
if (oldVersion <= 13) {
// remove duplicate rows in "Chapters" table that were created because of a bug.
db.execSQL(String.format("DELETE FROM %s WHERE %s NOT IN " +
"(SELECT MIN(%s) as %s FROM %s GROUP BY %s,%s,%s,%s,%s)",
PodDBAdapter.TABLE_NAME_SIMPLECHAPTERS,
PodDBAdapter.KEY_ID,
PodDBAdapter.KEY_ID,
PodDBAdapter.KEY_ID,
PodDBAdapter.TABLE_NAME_SIMPLECHAPTERS,
PodDBAdapter.KEY_TITLE,
PodDBAdapter.KEY_START,
PodDBAdapter.KEY_FEEDITEM,
PodDBAdapter.KEY_LINK,
PodDBAdapter.KEY_CHAPTER_TYPE));
}
} }
} }

View File

@ -143,7 +143,7 @@ public class FeedItem extends FeedComponent implements ShownotesProvider, Flattr
paymentLink = other.paymentLink; paymentLink = other.paymentLink;
} }
if (other.chapters != null) { if (other.chapters != null) {
if (chapters == null) { if (!hasChapters) {
chapters = other.chapters; chapters = other.chapters;
} }
} }