Clearing the snode and onion request dbs on launch

This commit is contained in:
ThomasSession
2024-07-23 15:34:46 +10:00
parent 6b55e37cda
commit 5809a428d6
6 changed files with 33 additions and 0 deletions

View File

@@ -214,6 +214,17 @@ public class ApplicationContext extends Application implements DefaultLifecycleO
DatabaseModule.init(this);
MessagingModuleConfiguration.configure(this);
super.onCreate();
// we need to clear the snode and onionrequest databases once on first launch
// in order to apply a patch that adds a version number to the Snode objects.
if(!TextSecurePreferences.hasAppliedPatchSnodeVersion(this)) {
ThreadUtils.queue(() -> {
lokiAPIDatabase.clearSnodePool();
lokiAPIDatabase.clearOnionRequestPaths();
TextSecurePreferences.setHasAppliedPatchSnodeVersion(this, true);
});
}
messagingModuleConfiguration = new MessagingModuleConfiguration(
this,
storage,

View File

@@ -255,6 +255,11 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(
return result
}
override fun clearSnodePool() {
val database = databaseHelper.writableDatabase
database.delete(snodePoolTable, null, null)
}
override fun clearOnionRequestPaths() {
val database = databaseHelper.writableDatabase
fun delete(indexPath: String) {