mirror of
https://github.com/ReVanced/revanced-manager.git
synced 2024-11-10 01:01:56 +01:00
fix: Move temporary files outside of the cache directory (#2122)
This commit is contained in:
parent
936a9efd0b
commit
e869db0555
4 changed files with 13 additions and 22 deletions
|
@ -1,10 +1,11 @@
|
|||
package app.revanced.manager.data.platform
|
||||
|
||||
import android.Manifest
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
import android.os.Environment
|
||||
import android.Manifest
|
||||
import android.content.pm.PackageManager
|
||||
import androidx.activity.result.contract.ActivityResultContract
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import app.revanced.manager.util.RequestManageStorageContract
|
||||
|
@ -16,7 +17,7 @@ class Filesystem(private val app: Application) {
|
|||
* A directory that gets cleared when the app restarts.
|
||||
* Do not store paths to this directory in a parcel.
|
||||
*/
|
||||
val tempDir = app.cacheDir.resolve("ephemeral").apply {
|
||||
val tempDir = app.getDir("ephemeral", Context.MODE_PRIVATE).apply {
|
||||
deleteRecursively()
|
||||
mkdirs()
|
||||
}
|
||||
|
|
|
@ -193,6 +193,9 @@ class PatcherWorker(
|
|||
Result.failure()
|
||||
} finally {
|
||||
patchedApk.delete()
|
||||
if (args.input is SelectedApp.Local && args.input.temporary) {
|
||||
args.input.file.delete()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ class AppSelectorViewModel(
|
|||
private val pm: PM,
|
||||
private val patchBundleRepository: PatchBundleRepository
|
||||
) : ViewModel() {
|
||||
private val inputFile = File(app.cacheDir, "input.apk").also {
|
||||
private val inputFile = File(app.filesDir, "input.apk").also {
|
||||
it.delete()
|
||||
}
|
||||
val appList = pm.appList
|
||||
|
|
|
@ -48,7 +48,6 @@ import kotlinx.coroutines.flow.StateFlow
|
|||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.time.withTimeout
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.coroutines.withTimeout
|
||||
import org.koin.core.component.KoinComponent
|
||||
import org.koin.core.component.inject
|
||||
import java.io.File
|
||||
|
@ -189,26 +188,14 @@ class PatcherViewModel(
|
|||
app.unregisterReceiver(installBroadcastReceiver)
|
||||
workManager.cancelWorkById(patcherWorkerId)
|
||||
|
||||
when (val selectedApp = input.selectedApp) {
|
||||
is SelectedApp.Local -> {
|
||||
if (selectedApp.temporary) selectedApp.file.delete()
|
||||
}
|
||||
|
||||
is SelectedApp.Installed -> {
|
||||
GlobalScope.launch(Dispatchers.Main) {
|
||||
uiSafe(app, R.string.failed_to_mount, "Failed to mount") {
|
||||
installedApp?.let {
|
||||
if (it.installType == InstallType.ROOT) {
|
||||
withTimeout(Duration.ofMinutes(1L)) {
|
||||
rootInstaller.mount(packageName)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (input.selectedApp is SelectedApp.Installed && installedApp?.installType == InstallType.ROOT) {
|
||||
GlobalScope.launch(Dispatchers.Main) {
|
||||
uiSafe(app, R.string.failed_to_mount, "Failed to mount") {
|
||||
withTimeout(Duration.ofMinutes(1L)) {
|
||||
rootInstaller.mount(packageName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else -> Unit
|
||||
}
|
||||
|
||||
tempDir.deleteRecursively()
|
||||
|
|
Loading…
Reference in a new issue