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
PublicAndroidApps
Nebulo
Commits
bd03835e
Commit
bd03835e
authored
Jun 24, 2019
by
Daniel Wolf
Browse files
Don't cascade deletion of host sources, instead delete the rules async
parent
91e96a9f
Pipeline
#4800
passed with stage
in 50 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/com/frostnerd/smokescreen/activity/DnsRuleActivity.kt
View file @
bd03835e
...
...
@@ -84,6 +84,7 @@ class DnsRuleActivity : BaseActivity() {
val
pos
=
sourceAdapterList
.
indexOf
(
it
)
sourceAdapterList
.
removeAt
(
pos
)
sourceAdapter
.
notifyItemRemoved
(
pos
)
getDatabase
().
dnsRuleRepository
().
deleteAllFromSourceAsync
(
it
)
getDatabase
().
hostSourceRepository
().
deleteAsync
(
it
)
dialog
.
dismiss
()
},
getString
(
R
.
string
.
all_no
)
to
{
dialog
,
_
->
...
...
app/src/main/java/com/frostnerd/smokescreen/database/dao/DnsRuleDao.kt
View file @
bd03835e
...
...
@@ -53,4 +53,7 @@ interface DnsRuleDao {
@Query
(
"SELECT target FROM DnsRule WHERE host=:host AND type = :type LIMIT 1"
)
fun
findRuleTarget
(
host
:
String
,
type
:
Record
.
TYPE
):
String
?
@Query
(
"DELETE FROM DnsRule WHERE importedFrom=:sourceId"
)
fun
deleteAllFromSource
(
sourceId
:
Long
)
}
\ No newline at end of file
app/src/main/java/com/frostnerd/smokescreen/database/entities/DnsRule.kt
View file @
bd03835e
...
...
@@ -28,7 +28,7 @@ import org.minidns.record.Record
entity
=
HostSource
::
class
,
parentColumns
=
arrayOf
(
"id"
),
childColumns
=
arrayOf
(
"importedFrom"
),
onDelete
=
ForeignKey
.
CASCADE
onDelete
=
ForeignKey
.
NO_ACTION
)],
indices
=
[
Index
(
"importedFrom"
),
Index
(
"host"
),
Index
(
"host"
,
"type"
)]
)
...
...
app/src/main/java/com/frostnerd/smokescreen/database/repository/DnsRuleRepository.kt
View file @
bd03835e
...
...
@@ -2,26 +2,27 @@ package com.frostnerd.smokescreen.database.repository
import
com.frostnerd.smokescreen.database.dao.DnsQueryDao
import
com.frostnerd.smokescreen.database.dao.DnsRuleDao
import
com.frostnerd.smokescreen.database.entities.HostSource
import
kotlinx.coroutines.CoroutineScope
import
kotlinx.coroutines.GlobalScope
import
kotlinx.coroutines.launch
/*
* Copyright (C) 2019 Daniel Wolf (Ch4t4r)
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
* You can contact the developer at daniel.wolf@frostnerd.com.
*/
class
DnsRuleRepository
(
val
dnsRuleDao
:
DnsRuleDao
)
{
...
...
@@ -31,4 +32,10 @@ class DnsRuleRepository(val dnsRuleDao: DnsRuleDao) {
dnsRuleDao
.
deleteAll
()
}
}
fun
deleteAllFromSourceAsync
(
hostSource
:
HostSource
,
coroutineScope
:
CoroutineScope
=
GlobalScope
)
{
coroutineScope
.
launch
{
dnsRuleDao
.
deleteAllFromSource
(
hostSource
.
id
)
}
}
}
\ No newline at end of file
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