mirror of
https://github.com/MaintainTeam/LastPipeBender.git
synced 2025-02-28 21:38:20 +03:00
attempt at rolling back bad database changes
This commit is contained in:
parent
a9ec54f908
commit
eb5bc4fa35
4 changed files with 24 additions and 41 deletions
|
@ -2,7 +2,7 @@
|
|||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 10,
|
||||
"identityHash": "377d92119f9bf8b38d1d4ec87453405e",
|
||||
"identityHash": "7591e8039faa74d8c0517dc867af9d3e",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "subscriptions",
|
||||
|
@ -719,32 +719,12 @@
|
|||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"tableName": "sponsorblock_whitelist",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`uploader` TEXT NOT NULL, PRIMARY KEY(`uploader`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "uploader",
|
||||
"columnName": "uploader",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"autoGenerate": false,
|
||||
"columnNames": [
|
||||
"uploader"
|
||||
]
|
||||
},
|
||||
"indices": [],
|
||||
"foreignKeys": []
|
||||
}
|
||||
],
|
||||
"views": [],
|
||||
"setupQueries": [
|
||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '377d92119f9bf8b38d1d4ec87453405e')"
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '7591e8039faa74d8c0517dc867af9d3e')"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package org.schabi.newpipe.database;
|
||||
|
||||
import static org.schabi.newpipe.database.Migrations.DB_VER_10;
|
||||
import static org.schabi.newpipe.database.Migrations.DB_VER_9;
|
||||
|
||||
import androidx.room.Database;
|
||||
import androidx.room.RoomDatabase;
|
||||
|
@ -22,8 +22,6 @@ import org.schabi.newpipe.database.playlist.dao.PlaylistStreamDAO;
|
|||
import org.schabi.newpipe.database.playlist.model.PlaylistEntity;
|
||||
import org.schabi.newpipe.database.playlist.model.PlaylistRemoteEntity;
|
||||
import org.schabi.newpipe.database.playlist.model.PlaylistStreamEntity;
|
||||
import org.schabi.newpipe.database.sponsorblock.dao.SponsorBlockWhitelistDAO;
|
||||
import org.schabi.newpipe.database.sponsorblock.dao.SponsorBlockWhitelistEntry;
|
||||
import org.schabi.newpipe.database.stream.dao.StreamDAO;
|
||||
import org.schabi.newpipe.database.stream.dao.StreamStateDAO;
|
||||
import org.schabi.newpipe.database.stream.model.StreamEntity;
|
||||
|
@ -38,9 +36,9 @@ import org.schabi.newpipe.database.subscription.SubscriptionEntity;
|
|||
StreamEntity.class, StreamHistoryEntity.class, StreamStateEntity.class,
|
||||
PlaylistEntity.class, PlaylistStreamEntity.class, PlaylistRemoteEntity.class,
|
||||
FeedEntity.class, FeedGroupEntity.class, FeedGroupSubscriptionEntity.class,
|
||||
FeedLastUpdatedEntity.class, SponsorBlockWhitelistEntry.class
|
||||
FeedLastUpdatedEntity.class
|
||||
},
|
||||
version = DB_VER_10
|
||||
version = DB_VER_9
|
||||
)
|
||||
public abstract class AppDatabase extends RoomDatabase {
|
||||
public static final String DATABASE_NAME = "newpipe.db";
|
||||
|
@ -64,6 +62,4 @@ public abstract class AppDatabase extends RoomDatabase {
|
|||
public abstract FeedGroupDAO feedGroupDAO();
|
||||
|
||||
public abstract SubscriptionDAO subscriptionDAO();
|
||||
|
||||
public abstract SponsorBlockWhitelistDAO sponsorBlockWhitelistDAO();
|
||||
}
|
||||
|
|
|
@ -252,9 +252,15 @@ public final class Migrations {
|
|||
database.execSQL("DELETE FROM search_history WHERE id NOT IN (SELECT id FROM (SELECT "
|
||||
+ "MIN(id) as id FROM search_history GROUP BY trim(search), service_id ) tmp)");
|
||||
database.execSQL("UPDATE search_history SET search = trim(search)");
|
||||
|
||||
// TODO: remove later - this meant to be a temporary fix for
|
||||
// "rolling back" the database to fix poly's dumb mistake...
|
||||
database.execSQL("DROP TABLE `sponsorblock_whitelist`");
|
||||
MIGRATION_9_10.migrate(database);
|
||||
}
|
||||
};
|
||||
|
||||
// TODO: change back to MIGRATION_8_9 = new Migration(DB_VER_8, DB_VER_9)
|
||||
public static final Migration MIGRATION_9_10 = new Migration(DB_VER_9, DB_VER_10) {
|
||||
@Override
|
||||
public void migrate(@NonNull final SupportSQLiteDatabase database) {
|
||||
|
|
|
@ -5,38 +5,39 @@ import android.content.Context;
|
|||
import org.schabi.newpipe.NewPipeDatabase;
|
||||
import org.schabi.newpipe.database.AppDatabase;
|
||||
import org.schabi.newpipe.database.sponsorblock.dao.SponsorBlockWhitelistDAO;
|
||||
import org.schabi.newpipe.database.sponsorblock.dao.SponsorBlockWhitelistEntry;
|
||||
|
||||
import io.reactivex.rxjava3.core.Completable;
|
||||
import io.reactivex.rxjava3.core.Maybe;
|
||||
import io.reactivex.rxjava3.core.Single;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
|
||||
public class SponsorBlockDataManager {
|
||||
private final SponsorBlockWhitelistDAO sponsorBlockWhitelistTable;
|
||||
private final SponsorBlockWhitelistDAO sponsorBlockWhitelistTable = null;
|
||||
|
||||
public SponsorBlockDataManager(final Context context) {
|
||||
final AppDatabase database = NewPipeDatabase.getInstance(context);
|
||||
sponsorBlockWhitelistTable = database.sponsorBlockWhitelistDAO();
|
||||
}
|
||||
|
||||
public Maybe<Long> addToWhitelist(final String uploader) {
|
||||
return Maybe.fromCallable(() -> {
|
||||
final SponsorBlockWhitelistEntry entry = new SponsorBlockWhitelistEntry(uploader);
|
||||
return sponsorBlockWhitelistTable.insert(entry);
|
||||
}).subscribeOn(Schedulers.io());
|
||||
// return Maybe.fromCallable(() -> {
|
||||
// final SponsorBlockWhitelistEntry entry = new SponsorBlockWhitelistEntry(uploader);
|
||||
// return sponsorBlockWhitelistTable.insert(entry);
|
||||
// }).subscribeOn(Schedulers.io());
|
||||
return Maybe.empty();
|
||||
}
|
||||
|
||||
public Completable removeFromWhitelist(final String uploader) {
|
||||
return Completable.fromAction(() -> sponsorBlockWhitelistTable.deleteByUploader(uploader));
|
||||
// return Completable.fromAction(() -> sponsorBlockWhitelistTable.deleteByUploader(uploader));
|
||||
return Completable.complete();
|
||||
}
|
||||
|
||||
public Single<Boolean> isWhiteListed(final String uploader) {
|
||||
return Single.fromCallable(() -> sponsorBlockWhitelistTable.exists(uploader))
|
||||
.subscribeOn(Schedulers.io());
|
||||
// return Single.fromCallable(() -> sponsorBlockWhitelistTable.exists(uploader))
|
||||
// .subscribeOn(Schedulers.io());
|
||||
return Single.just(false);
|
||||
}
|
||||
|
||||
public Completable clearWhitelist() {
|
||||
return Completable.fromAction(sponsorBlockWhitelistTable::deleteAll);
|
||||
// return Completable.fromAction(sponsorBlockWhitelistTable::deleteAll);
|
||||
return Completable.complete();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue