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
ff828116
Commit
ff828116
authored
Sep 05, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only cache magisk zips
parent
ee39616a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
39 deletions
+6
-39
Config.kt
app/src/main/java/com/topjohnwu/magisk/Config.kt
+0
-2
RemoteFileService.kt
.../com/topjohnwu/magisk/model/download/RemoteFileService.kt
+6
-25
app_settings.xml
app/src/main/res/xml/app_settings.xml
+0
-12
No files found.
app/src/main/java/com/topjohnwu/magisk/Config.kt
View file @
ff828116
...
...
@@ -47,7 +47,6 @@ object Config : PreferenceModel, DBConfig {
const
val
DARK_THEME
=
"dark_theme"
const
val
REPO_ORDER
=
"repo_order"
const
val
SHOW_SYSTEM_APP
=
"show_system"
const
val
DOWNLOAD_CACHE
=
"download_cache"
const
val
DOWNLOAD_PATH
=
"download_path"
// system state
...
...
@@ -101,7 +100,6 @@ object Config : PreferenceModel, DBConfig {
if
(
Utils
.
isCanary
)
Value
.
CANARY_DEBUG_CHANNEL
else
Value
.
DEFAULT_CHANNEL
var
isDownloadCacheEnabled
by
preference
(
Key
.
DOWNLOAD_CACHE
,
true
)
var
downloadPath
by
preference
(
Key
.
DOWNLOAD_PATH
,
Environment
.
DIRECTORY_DOWNLOADS
)
var
repoOrder
by
preference
(
Key
.
REPO_ORDER
,
Value
.
ORDER_DATE
)
...
...
app/src/main/java/com/topjohnwu/magisk/model/download/RemoteFileService.kt
View file @
ff828116
...
...
@@ -4,11 +4,9 @@ import android.app.Activity
import
android.content.Intent
import
androidx.core.app.NotificationCompat
import
com.skoumal.teanity.extensions.subscribeK
import
com.topjohnwu.magisk.Config
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.data.network.GithubRawServices
import
com.topjohnwu.magisk.di.NullActivity
import
com.topjohnwu.magisk.extensions.firstMap
import
com.topjohnwu.magisk.extensions.get
import
com.topjohnwu.magisk.extensions.writeTo
import
com.topjohnwu.magisk.model.entity.internal.DownloadSubject
...
...
@@ -20,19 +18,12 @@ import io.reactivex.Completable
import
okhttp3.ResponseBody
import
org.koin.android.ext.android.inject
import
timber.log.Timber
import
java.io.File
import
java.io.InputStream
abstract
class
RemoteFileService
:
NotificationService
()
{
private
val
service
:
GithubRawServices
by
inject
()
private
val
supportedFolders
get
()
=
listOf
(
cacheDir
,
Config
.
downloadDirectory
)
override
val
defaultNotification
:
NotificationCompat
.
Builder
get
()
=
Notifications
.
progress
(
this
,
""
)
...
...
@@ -43,7 +34,7 @@ abstract class RemoteFileService : NotificationService() {
// ---
private
fun
start
(
subject
:
DownloadSubject
)
=
search
(
subject
)
private
fun
start
(
subject
:
DownloadSubject
)
=
checkExisting
(
subject
)
.
onErrorResumeNext
{
download
(
subject
)
}
.
doOnSubscribe
{
update
(
subject
.
hashCode
())
{
it
.
setContentTitle
(
subject
.
title
)
}
}
.
subscribeK
(
onError
=
{
...
...
@@ -60,16 +51,12 @@ abstract class RemoteFileService : NotificationService() {
}
}
private
fun
search
(
subject
:
DownloadSubject
)
=
Completable
.
fromAction
{
if
(!
Config
.
isDownloadCacheEnabled
||
subject
is
Manager
)
{
throw
IllegalStateException
(
"The download cache is disabled"
)
}
private
fun
checkExisting
(
subject
:
DownloadSubject
)
=
Completable
.
fromAction
{
check
(
subject
is
Magisk
)
{
"Download cache is disabled"
}
supportedFolders
.
firstMap
{
it
.
find
(
subject
.
file
.
name
)
}.
also
{
if
(
subject
is
Magisk
)
{
if
(!
ShellUtils
.
checkSum
(
"MD5"
,
it
,
subject
.
magisk
.
md5
))
{
throw
IllegalStateException
(
"The given file doesn't match the md5"
)
}
subject
.
file
.
also
{
check
(
it
.
exists
()
&&
ShellUtils
.
checkSum
(
"MD5"
,
it
,
subject
.
magisk
.
md5
))
{
"The given file does not match checksum"
}
}
}
...
...
@@ -88,12 +75,6 @@ abstract class RemoteFileService : NotificationService() {
handleAPK
(
subject
)
}
// ---
private
fun
File
.
find
(
name
:
String
)
=
list
()
?.
firstOrNull
{
it
==
name
}
?.
let
{
File
(
this
,
it
)
}
private
fun
ResponseBody
.
toStream
(
id
:
Int
):
InputStream
{
val
maxRaw
=
contentLength
()
val
max
=
maxRaw
/
1
_000_000f
...
...
app/src/main/res/xml/app_settings.xml
View file @
ff828116
...
...
@@ -29,18 +29,6 @@
android:summary=
"@string/settings_restore_manager_summary"
android:title=
"@string/settings_restore_manager_title"
/>
</PreferenceCategory>
<PreferenceCategory
android:key=
"downloads"
android:title=
"@string/settings_downloads_category"
>
<SwitchPreferenceCompat
android:defaultValue=
"true"
android:key=
"download_cache"
android:summary=
"@string/settings_download_cache_summary"
android:title=
"@string/settings_download_cache_title"
/>
<Preference
android:key=
"download_path"
android:title=
"@string/settings_download_path_title"
/>
...
...
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