Commit 91c3f1d5 authored by Daniel Wolf's avatar Daniel Wolf
Browse files

Fix no rule being deleted when no source is selected

parent 7d52441c
...@@ -45,8 +45,11 @@ interface DnsRuleDao { ...@@ -45,8 +45,11 @@ interface DnsRuleDao {
@Query("DELETE FROM DnsRule WHERE importedFrom IS NULL") @Query("DELETE FROM DnsRule WHERE importedFrom IS NULL")
fun deleteAllUserRules() fun deleteAllUserRules()
@Query("UPDATE DnsRule SET stagingType=1 WHERE importedFrom IS NOT NULL AND stagingType=0 AND importedFrom IN(:sources)") @Query("DELETE FROM DnsRule WHERE importedFrom IS NOT NULL")
fun markNonUserRulesForDeletion(sources:List<Long>) fun deleteAllNonUserRules()
@Query("UPDATE DnsRule SET stagingType=1 WHERE importedFrom IS NOT NULL AND stagingType=0")
fun markNonUserRulesForDeletion()
@Query("UPDATE DnsRule SET stagingType=0 WHERE importedFrom=:hostSourceId AND stagingType=1") @Query("UPDATE DnsRule SET stagingType=0 WHERE importedFrom=:hostSourceId AND stagingType=1")
fun unstageRulesOfSource(hostSourceId:Long) fun unstageRulesOfSource(hostSourceId:Long)
......
...@@ -174,7 +174,7 @@ class RuleImportService : IntentService("RuleImportService") { ...@@ -174,7 +174,7 @@ class RuleImportService : IntentService("RuleImportService") {
private fun startWork() { private fun startWork() {
val dnsRuleDao = getDatabase().dnsRuleDao() val dnsRuleDao = getDatabase().dnsRuleDao()
dnsRuleDao.markNonUserRulesForDeletion(sourcesIds) // Stage all, ignoring if the source is actually processed in this run dnsRuleDao.markNonUserRulesForDeletion() // Stage all, ignoring if the source is actually processed in this run
dnsRuleDao.deleteStagedRules() dnsRuleDao.deleteStagedRules()
var count = 0 var count = 0
val newChecksums = mutableMapOf<HostSource, String>() val newChecksums = mutableMapOf<HostSource, String>()
...@@ -244,7 +244,7 @@ class RuleImportService : IntentService("RuleImportService") { ...@@ -244,7 +244,7 @@ class RuleImportService : IntentService("RuleImportService") {
updateNotificationFinishing() updateNotificationFinishing()
log("Delete rules staged for deletion") log("Delete rules staged for deletion")
dnsRuleDao.deleteMarkedRules() dnsRuleDao.deleteMarkedRules()
log("Commiting staging") log("Committing staging")
dnsRuleDao.commitStaging() dnsRuleDao.commitStaging()
dnsRuleDao.deleteStagedRules() dnsRuleDao.deleteStagedRules()
log("Recreating database indices") log("Recreating database indices")
......
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