Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Nathan OBrian
Nebulo
Commits
a06cab15
Commit
a06cab15
authored
Jun 05, 2021
by
Daniel Wolf
Browse files
Simply delete all rules when no sources are given
parent
8395b9d3
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/com/frostnerd/smokescreen/database/dao/DnsRuleDao.kt
View file @
a06cab15
...
...
@@ -48,8 +48,8 @@ interface DnsRuleDao {
@Query
(
"DELETE FROM DnsRule WHERE importedFrom IS NOT NULL"
)
fun
deleteAllNonUserRules
()
@Query
(
"UPDATE DnsRule SET stagingType=1 WHERE importedFrom IS NOT NULL AND stagingType=0"
)
fun
markNonUserRulesForDeletion
()
@Query
(
"UPDATE DnsRule SET stagingType=1 WHERE importedFrom IS NOT NULL AND stagingType=0
AND importedFrom IN(:sources)
"
)
fun
markNonUserRulesForDeletion
(
sources
:
List
<
Long
>
)
@Query
(
"UPDATE DnsRule SET stagingType=0 WHERE importedFrom=:hostSourceId AND stagingType=1"
)
fun
unstageRulesOfSource
(
hostSourceId
:
Long
)
...
...
app/src/main/java/com/frostnerd/smokescreen/service/RuleImportService.kt
View file @
a06cab15
...
...
@@ -174,8 +174,12 @@ class RuleImportService : IntentService("RuleImportService") {
private
fun
startWork
()
{
val
dnsRuleDao
=
getDatabase
().
dnsRuleDao
()
dnsRuleDao
.
markNonUserRulesForDeletion
()
// Stage all, ignoring if the source is actually processed in this run
dnsRuleDao
.
deleteStagedRules
()
if
(
sourcesIds
.
isEmpty
())
{
dnsRuleDao
.
deleteAllNonUserRules
()
}
else
{
dnsRuleDao
.
markNonUserRulesForDeletion
(
sourcesIds
)
// Stage all, ignoring if the source is actually processed in this run
dnsRuleDao
.
deleteStagedRules
()
}
var
count
=
0
val
newChecksums
=
mutableMapOf
<
HostSource
,
String
>()
sources
.
forEach
{
...
...
@@ -242,11 +246,13 @@ class RuleImportService : IntentService("RuleImportService") {
}
if
(!
isAborted
)
{
updateNotificationFinishing
()
log
(
"Delete rules staged for deletion"
)
dnsRuleDao
.
deleteMarkedRules
()
log
(
"Committing staging"
)
dnsRuleDao
.
commitStaging
()
dnsRuleDao
.
deleteStagedRules
()
if
(
sourcesIds
.
isNotEmpty
())
{
log
(
"Delete rules staged for deletion"
)
dnsRuleDao
.
deleteMarkedRules
()
log
(
"Committing staging"
)
dnsRuleDao
.
commitStaging
()
dnsRuleDao
.
deleteStagedRules
()
}
log
(
"Recreating database indices"
)
getDatabase
().
recreateDnsRuleIndizes
()
log
(
"Updating Etag values for sources"
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment