use triedEmptyUpdate methods in Preferences throughout the codebase

We have these methods, they should be used!
This commit is contained in:
Hans-Christoph Steiner 2018-01-31 16:18:13 +01:00
parent d8879dd425
commit 6d011c3895
2 changed files with 8 additions and 13 deletions

View File

@ -28,20 +28,19 @@ import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.util.Log;
import org.fdroid.fdroid.Preferences;
import org.fdroid.fdroid.R;
import org.fdroid.fdroid.Utils;
import org.fdroid.fdroid.data.Schema.AntiFeatureTable;
import org.fdroid.fdroid.data.Schema.ApkAntiFeatureJoinTable;
import org.fdroid.fdroid.data.Schema.ApkTable;
import org.fdroid.fdroid.data.Schema.CatJoinTable;
import org.fdroid.fdroid.data.Schema.PackageTable;
import org.fdroid.fdroid.data.Schema.AppPrefsTable;
import org.fdroid.fdroid.data.Schema.AppMetadataTable;
import org.fdroid.fdroid.data.Schema.AppPrefsTable;
import org.fdroid.fdroid.data.Schema.CatJoinTable;
import org.fdroid.fdroid.data.Schema.InstalledAppTable;
import org.fdroid.fdroid.data.Schema.PackageTable;
import org.fdroid.fdroid.data.Schema.RepoTable;
import java.util.ArrayList;
@ -1095,10 +1094,7 @@ public class DBHelper extends SQLiteOpenHelper {
private void resetTransient(SQLiteDatabase db) {
Utils.debugLog(TAG, "Removing app + apk tables so they can be recreated. Next time F-Droid updates it should trigger an index update.");
PreferenceManager.getDefaultSharedPreferences(context)
.edit()
.putBoolean("triedEmptyUpdate", false)
.apply();
Preferences.get().setTriedEmptyUpdate(false);
db.beginTransaction();
try {
@ -1150,10 +1146,7 @@ public class DBHelper extends SQLiteOpenHelper {
return;
}
PreferenceManager.getDefaultSharedPreferences(context)
.edit()
.putBoolean("triedEmptyUpdate", false)
.apply();
Preferences.get().setTriedEmptyUpdate(false);
db.execSQL("drop table " + AppMetadataTable.NAME);
db.execSQL("drop table " + ApkTable.NAME);

View File

@ -7,6 +7,7 @@ import android.content.ContextWrapper;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import org.fdroid.fdroid.BuildConfig;
import org.fdroid.fdroid.Preferences;
import org.fdroid.fdroid.TestUtils;
import org.fdroid.fdroid.Utils;
import org.junit.Before;
@ -34,6 +35,7 @@ public class DatabaseMigration {
@Test
public void migrationsFromDbVersion42Onward() {
Preferences.setupForTests(context);
SQLiteOpenHelper opener = new MigrationRunningOpenHelper(context);
opener.getReadableDatabase();
}