Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
8d50dfd9
Commit
8d50dfd9
authored
Jul 10, 2019
by
Viktor De Pasquale
Committed by
John Wu
Jul 20, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed overwriting file in download mode
Added prevention of copying itself to itself
parent
51e40dd9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
SubstrateDownloadService.kt
...pjohnwu/magisk/model/download/SubstrateDownloadService.kt
+6
-2
No files found.
app/src/main/java/com/topjohnwu/magisk/model/download/SubstrateDownloadService.kt
View file @
8d50dfd9
...
@@ -22,6 +22,7 @@ import com.topjohnwu.superuser.ShellUtils
...
@@ -22,6 +22,7 @@ import com.topjohnwu.superuser.ShellUtils
import
io.reactivex.Single
import
io.reactivex.Single
import
okhttp3.ResponseBody
import
okhttp3.ResponseBody
import
org.koin.android.ext.android.inject
import
org.koin.android.ext.android.inject
import
timber.log.Timber
import
java.io.File
import
java.io.File
import
kotlin.random.Random.Default.nextInt
import
kotlin.random.Random.Default.nextInt
...
@@ -51,7 +52,7 @@ abstract class SubstrateDownloadService : Service() {
...
@@ -51,7 +52,7 @@ abstract class SubstrateDownloadService : Service() {
private
fun
start
(
subject
:
DownloadSubject
)
=
search
(
subject
)
private
fun
start
(
subject
:
DownloadSubject
)
=
search
(
subject
)
.
onErrorResumeNext
(
download
(
subject
))
.
onErrorResumeNext
(
download
(
subject
))
.
subscribeK
{
.
subscribeK
{
runCatching
{
onFinished
(
it
,
subject
)
}
runCatching
{
onFinished
(
it
,
subject
)
}
.
onFailure
{
Timber
.
e
(
it
)
}
finish
(
it
,
subject
)
finish
(
it
,
subject
)
}
}
...
@@ -93,7 +94,10 @@ abstract class SubstrateDownloadService : Service() {
...
@@ -93,7 +94,10 @@ abstract class SubstrateDownloadService : Service() {
protected
fun
moveToDownloads
(
file
:
File
)
{
protected
fun
moveToDownloads
(
file
:
File
)
{
val
destination
=
downloadsFile
(
file
.
name
)
val
destination
=
downloadsFile
(
file
.
name
)
file
.
copyTo
(
destination
)
if
(
file
!=
destination
)
{
destination
.
deleteRecursively
()
file
.
copyTo
(
destination
)
}
toast
(
getString
(
R
.
string
.
internal_storage
,
"/Download/${file.name}"
),
Toast
.
LENGTH_LONG
)
toast
(
getString
(
R
.
string
.
internal_storage
,
"/Download/${file.name}"
),
Toast
.
LENGTH_LONG
)
}
}
...
...
Write
Preview
Markdown
is supported
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