fix: listBackupFiles 跳过 Java 空数组回落 root shell

FUSE 文件系统可能将 EPERM 表现为空数组而非 null,
导致 listBackupFiles 提前返回 [] 从未执行 ls -1 回落。
改为仅当 Java 返回非空结果才提前返回,空数组继续走 root shell。
This commit is contained in:
sakuradairong
2026-06-08 15:11:17 +08:00
parent b249942c13
commit 8122f64923
2 changed files with 7 additions and 1 deletions

View File

@@ -460,7 +460,13 @@ object BackupOperation {
*/
internal suspend fun listBackupFiles(dir: File): List<String>? {
try {
return dir.listFiles()?.map { it.name }
val javaFiles = dir.listFiles()
if (javaFiles != null) {
val names = javaFiles.map { it.name }
if (names.isNotEmpty()) return names
// Java returned empty — FUSE may report EPERM as empty array
// Fall through to root shell ls for definitive answer
}
} catch (_: Exception) { /* fall through */ }
try {
val result = RootShell.exec("ls -1 '${dir.absolutePath.shellEscape()}' 2>/dev/null")