mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-22 22:36:00 +00:00
fix(storage): reset prefix review fixes
This commit is contained in:
1 parent
7dc447e65c
commit
6af6ff1926
3 files changed
+10
-8
No files matched your search
@@ -175,8 +175,8 @@ object StorageScan {
|
||||
}
|
||||
if (!m.installed) continue
|
||||
val gameBytes = dir?.let { File(lib.root, "steamapps/common/$it") }?.takeIf { it.isDirectory }?.let { walker.measure(it) } ?: 0
|
||||
val prefixDir = File(lib.data, "steamapps/compatdata/${m.appId}").takeIf { it.isDirectory }
|
||||
val prefix = prefixDir?.let { walker.measure(it) } ?: 0
|
||||
val prefixDir = sequenceOf(lib.data, lib.root).map { File(it, "steamapps/compatdata/${m.appId}") }.firstOrNull { it.isDirectory }
|
||||
val prefix = File(lib.data, "steamapps/compatdata/${m.appId}").takeIf { it.isDirectory }?.let { walker.measure(it) } ?: 0
|
||||
val shaderDir = File(lib.data, "steamapps/shadercache/${m.appId}").takeIf { it.isDirectory }
|
||||
val shaders = shaderDir?.let { walker.measure(it) } ?: 0
|
||||
val workshop = File(lib.root, "steamapps/workshop/content/${m.appId}").takeIf { it.isDirectory }?.let { walker.measure(it) } ?: 0
|
||||
|
||||
@@ -140,9 +140,11 @@ object StorageState {
|
||||
FileOps.delete(dir)
|
||||
})
|
||||
|
||||
fun resetPrefix(context: Context, appId: Int, x64: Boolean = false) = act(context, "prefix-$appId", { _, fresh ->
|
||||
val dir = fresh.games.firstOrNull { it.appId == appId && it.x64 == x64 }?.prefixDir ?: return@act false
|
||||
FileOps.delete(dir)
|
||||
fun resetPrefix(context: Context, game: GameUsage) = act(context, "prefix-${game.appId}", { _, fresh ->
|
||||
val dir = fresh.games.firstOrNull { it.appId == game.appId && it.x64 == game.x64 && it.prefixDir?.path == game.prefixDir?.path }
|
||||
?.prefixDir ?: return@act false
|
||||
check(FileOps.delete(dir)) { "cannot delete $dir" }
|
||||
true
|
||||
})
|
||||
|
||||
fun removeLeftover(context: Context, l: Leftover) = act(context, "leftover-${l.appId}", { _, fresh ->
|
||||
|
||||
@@ -850,7 +850,7 @@ private fun GameDataView(report: StorageReport, sessionRunning: Boolean, onBack:
|
||||
SubHeader(stringResource(R.string.storage_game_data), stringResource(R.string.storage_game_data_hint, gb(report.prefixes), gb(report.workshop), gb(report.shaders)), onBack)
|
||||
ActionStatus()
|
||||
if (sessionRunning) { Note(stringResource(R.string.storage_session_running)); Spacer(Modifier.height(4.dp)) }
|
||||
val games = report.games.filter { it.data >= ONE_MB }.sortedByDescending { it.data }
|
||||
val games = report.games.filter { it.data >= ONE_MB || it.prefixDir != null }.sortedByDescending { it.data }
|
||||
SectionTitle(stringResource(R.string.storage_data_installed), gb(games.sumOf { it.data }))
|
||||
ListCard {
|
||||
if (games.isEmpty()) Text(stringResource(R.string.storage_no_games), fontSize = 14.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.padding(16.dp))
|
||||
@@ -860,7 +860,7 @@ private fun GameDataView(report: StorageReport, sessionRunning: Boolean, onBack:
|
||||
action = {
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
SecondaryButton(stringResource(R.string.storage_clear_shaders), compact = true, enabled = !busy && g.shaders >= ONE_MB) { StorageState.clearShaders(ctx, g.appId, g.x64) }
|
||||
SecondaryButton(stringResource(R.string.storage_reset_prefix), compact = true, enabled = !busy && g.prefix >= ONE_MB) { confirmPrefix = g }
|
||||
SecondaryButton(stringResource(R.string.storage_reset_prefix), compact = true, enabled = !busy && g.prefixDir != null) { confirmPrefix = g }
|
||||
}
|
||||
},
|
||||
)
|
||||
@@ -898,7 +898,7 @@ private fun GameDataView(report: StorageReport, sessionRunning: Boolean, onBack:
|
||||
ConfirmDialog(
|
||||
stringResource(R.string.storage_reset_prefix_title, gameName(g)),
|
||||
stringResource(R.string.storage_reset_prefix_confirm, gb(g.prefix)), stringResource(R.string.storage_reset_prefix),
|
||||
onConfirm = { StorageState.resetPrefix(ctx, g.appId, g.x64) }, onDismiss = { confirmPrefix = null },
|
||||
onConfirm = { StorageState.resetPrefix(ctx, g) }, onDismiss = { confirmPrefix = null },
|
||||
)
|
||||
}
|
||||
confirm?.let { l ->
|
||||
|
||||
Reference in new issue
Block a user