feat(PatchingScreen): only clear incomplete DownloadSteps when cancelling patching early
This commit is contained in:
parent
f3547048e3
commit
e6cb0696d4
3 changed files with 14 additions and 8 deletions
|
|
@ -109,7 +109,7 @@ class PatchingScreen(private val data: PatchOptions) : Screen, Parcelable {
|
||||||
onDismiss = { showAbortWarning = false },
|
onDismiss = { showAbortWarning = false },
|
||||||
onConfirm = {
|
onConfirm = {
|
||||||
navigator.back(currentActivity = null)
|
navigator.back(currentActivity = null)
|
||||||
model.clearCache()
|
model.cancelInstall()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -265,7 +265,7 @@ class PatchingScreen(private val data: PatchOptions) : Screen, Parcelable {
|
||||||
),
|
),
|
||||||
onClick = {
|
onClick = {
|
||||||
cacheCleared = true
|
cacheCleared = true
|
||||||
model.clearCache()
|
model.cancelInstall()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,12 +14,12 @@ import com.aliucord.manager.manager.*
|
||||||
import com.aliucord.manager.patcher.KotlinPatchRunner
|
import com.aliucord.manager.patcher.KotlinPatchRunner
|
||||||
import com.aliucord.manager.patcher.StepRunner
|
import com.aliucord.manager.patcher.StepRunner
|
||||||
import com.aliucord.manager.patcher.steps.StepGroup
|
import com.aliucord.manager.patcher.steps.StepGroup
|
||||||
import com.aliucord.manager.patcher.steps.base.Step
|
import com.aliucord.manager.patcher.steps.base.*
|
||||||
import com.aliucord.manager.patcher.steps.base.StepState
|
|
||||||
import com.aliucord.manager.patcher.steps.install.InstallStep
|
import com.aliucord.manager.patcher.steps.install.InstallStep
|
||||||
import com.aliucord.manager.ui.screens.log.LogScreen
|
import com.aliucord.manager.ui.screens.log.LogScreen
|
||||||
import com.aliucord.manager.ui.screens.patchopts.PatchOptions
|
import com.aliucord.manager.ui.screens.patchopts.PatchOptions
|
||||||
import com.aliucord.manager.ui.util.toUnsafeImmutable
|
import com.aliucord.manager.ui.util.toUnsafeImmutable
|
||||||
|
import com.aliucord.manager.util.launchBlock
|
||||||
import com.aliucord.manager.util.showToast
|
import com.aliucord.manager.util.showToast
|
||||||
import kotlinx.collections.immutable.ImmutableList
|
import kotlinx.collections.immutable.ImmutableList
|
||||||
import kotlinx.collections.immutable.ImmutableMap
|
import kotlinx.collections.immutable.ImmutableMap
|
||||||
|
|
@ -76,9 +76,15 @@ class PatchingScreenModel(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun clearCache() {
|
fun cancelInstall() = screenModelScope.launchBlock(Dispatchers.IO) {
|
||||||
screenModelScope.launch { paths.clearCache() }
|
runnerJob?.cancel("Manual cancellation")
|
||||||
application.showToast(R.string.action_cleared_cache)
|
|
||||||
|
val incompleteDownloadStep = stepRunner?.steps
|
||||||
|
?.filterIsInstance<DownloadStep>()
|
||||||
|
?.lastOrNull { it.state == StepState.Running }
|
||||||
|
|
||||||
|
incompleteDownloadStep?.targetFile?.delete()
|
||||||
|
paths.patchingWorkingDir().deleteRecursively()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun install() = screenModelScope.launch {
|
fun install() = screenModelScope.launch {
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,7 @@
|
||||||
<string name="status_failed">Failed</string>
|
<string name="status_failed">Failed</string>
|
||||||
|
|
||||||
<string name="installer_abort_title">Really exit?</string>
|
<string name="installer_abort_title">Really exit?</string>
|
||||||
<string name="installer_abort_body">Are you sure you really want to abort an in-progress installation? Cached files will be cleared to avoid corruption.</string>
|
<string name="installer_abort_body">Are you sure you really want to abort an in-progress installation?</string>
|
||||||
|
|
||||||
<string name="updater_body">A new update has been released for Aliucord Manager! It may be required in order to function properly. Would you like to update?</string>
|
<string name="updater_body">A new update has been released for Aliucord Manager! It may be required in order to function properly. Would you like to update?</string>
|
||||||
<string name="updater_title">Update to %1$s</string>
|
<string name="updater_title">Update to %1$s</string>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue