fix(frontend): game file export no longer fails before the game library folder exists (#2549)

* fix(frontend): game file export no longer fails before the game library folder exists

* fix(frontend): previous automatic library check accepts a library folder not created yet
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-11-15 09:37:30 -05:00
1 parent b424bfa353
commit 56fabbdbf0
2 files changed
+53 -2

No files matched your search

@@ -43,11 +43,14 @@ object GameFileSync {
val storageSetting = SessionPrefs.gameStorage(context)
val previousStorage = prefs(context).getString("storagePath", null)
if (storageSetting.isEmpty() && prefs(context).getString("storageSetting", null) == storageSetting && previousStorage != null) {
check(File(previousStorage).isDirectory) { context.getString(R.string.game_sync_err_previous_sd) }
check(libraryReadable(File(previousStorage))) { context.getString(R.string.game_sync_err_previous_sd) }
}
storage?.let { check(File(it.path).listFiles() != null) { context.getString(R.string.game_sync_err_game_storage) } }
storage?.let { check(libraryReadable(File(it.path))) { context.getString(R.string.game_sync_err_game_storage) } }
AddedGames.roots(context).forEach { check(it.host.listFiles() != null) { context.getString(R.string.game_sync_err_added_games) } }
GameFiles.sync(context, folder, Library.launchableGames(context, strictRead = true))
prefs(context).edit().putString("storageSetting", storageSetting).putString("storagePath", storage?.path).apply()
}
internal fun libraryReadable(dir: File): Boolean =
dir.listFiles() != null || (!dir.exists() && dir.parentFile?.isDirectory == true)
}