Commit b8f46af7 authored by Daniel Wolf's avatar Daniel Wolf
Browse files

Recreate the dns rules indices after importing

Implements #97
parent 2a8940fa
......@@ -49,4 +49,18 @@ abstract class AppDatabase : RoomDatabase() {
fun dnsQueryRepository() = DnsQueryRepository(dnsQueryDao())
fun dnsRuleRepository() = DnsRuleRepository(dnsRuleDao())
fun hostSourceRepository() = HostSourceRepository(hostSourceDao())
fun recreateDnsRuleIndizes() {
this.openHelper.writableDatabase.apply {
runInTransaction {
execSQL("DROP INDEX `index_DnsRule_importedFrom`")
execSQL("DROP INDEX `index_DnsRule_host`")
execSQL("DROP INDEX `index_DnsRule_host_type`")
execSQL("CREATE INDEX `index_DnsRule_importedFrom` ON `DnsRule` (`importedFrom`)")
execSQL("CREATE INDEX `index_DnsRule_host` ON `DnsRule` (`host`)")
execSQL("CREATE INDEX `index_DnsRule_host_type` ON `DnsRule` (`host`, `type`)")
}
}
}
}
\ No newline at end of file
......@@ -203,6 +203,7 @@ class RuleImportService : Service() {
updateNotificationFinishing()
dnsRuleDao.deleteMarkedRules()
dnsRuleDao.commitStaging()
getDatabase().recreateDnsRuleIndizes()
showSuccessNotification()
}
log("All imports finished.")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment