fix: ensure directory exists when listing custom component files

This commit is contained in:
rushiiMachine 2025-04-09 20:20:18 -07:00
parent 96a463349c
commit f3547048e3
No known key found for this signature in database
GPG key ID: DCBE5952BB3B6420
3 changed files with 8 additions and 4 deletions

View file

@ -107,8 +107,12 @@ class PathManager(
/** /**
* List all the files that follow the ```[SemVer].custom.*``` naming scheme. * List all the files that follow the ```[SemVer].custom.*``` naming scheme.
*/ */
private fun listCustomFiles(dir: File): List<SemVer> { private fun listCustomFiles(dir: File): List<SemVer>? {
val files = dir.listFiles() ?: return emptyList() if (!dir.exists()) return null
val files = dir.listFiles()
?: throw Error("Failed to list directory")
val customVersions = files val customVersions = files
.map { it.nameWithoutExtension } .map { it.nameWithoutExtension }
.filter { it.endsWith(".custom") } .filter { it.endsWith(".custom") }

View file

@ -39,7 +39,7 @@ class DownloadInjectorStep : DownloadStep(), IDexProvider, KoinComponent {
override suspend fun execute(container: StepRunner) { override suspend fun execute(container: StepRunner) {
val customVersions = mutableStateListOf<SemVer>() val customVersions = mutableStateListOf<SemVer>()
.apply { addAll(paths.customInjectorDexs()) } customVersions += paths.customInjectorDexs() ?: emptyList()
// Prompt to select or manage custom versions instead of downloading // Prompt to select or manage custom versions instead of downloading
if (customVersions.isNotEmpty()) { if (customVersions.isNotEmpty()) {

View file

@ -37,7 +37,7 @@ class DownloadPatchesStep : DownloadStep(), KoinComponent {
override suspend fun execute(container: StepRunner) { override suspend fun execute(container: StepRunner) {
val customVersions = mutableStateListOf<SemVer>() val customVersions = mutableStateListOf<SemVer>()
.apply { addAll(paths.customSmaliPatches()) } customVersions += paths.customSmaliPatches() ?: emptyList()
// Prompt to select or manage custom versions instead of downloading // Prompt to select or manage custom versions instead of downloading
if (customVersions.isNotEmpty()) { if (customVersions.isNotEmpty()) {