mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 20:36:04 +00:00
fix: adding a games folder on an SD card found nothing (#1153)
Adding a folder on an SD card outside the Steam library added nothing and said "Nothing new in this folder": every game's exe had no guest path, so each one was skipped. Since #542 nothing created the game-folder binds that let older builds use such folders; only migrated ones remained. addFolder now binds the picked folder under /root/Games (named as GamesFolderMigration names them, with a suffix when the name is taken) when the session cannot see it, then adds its games. The bind is mounted from the next session start.
This commit is contained in:
1 parent
aa6fae1924
commit
8e02904a04
2 files changed
+61
No files matched your search
@@ -243,6 +243,8 @@ object AddedGames {
|
||||
|
||||
fun addFolder(context: Context, dir: File, onGame: (Game) -> Unit = {}, onChecking: (String?) -> Unit = {}): FolderResult {
|
||||
val app = context.applicationContext
|
||||
// Binds are mounted at session start, so a new one reaches the session from the next start.
|
||||
if (guestPath(app, dir) == null) bindFolder(app, dir)
|
||||
val removed = SessionPrefs.removedAddedGames(app).toSet()
|
||||
val listed = listedFolders(app, removed)
|
||||
var already = 0
|
||||
@@ -266,6 +268,20 @@ object AddedGames {
|
||||
return FolderResult(added, already)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
internal fun bindFolder(context: Context, dir: File) {
|
||||
if (!dir.isDirectory || !dir.canRead()) return
|
||||
val binds = SessionPrefs.gameFolderBinds(context)
|
||||
if (binds.any { it.first == dir.path }) return
|
||||
val taken = binds.map { it.second }.toSet()
|
||||
val base = GamesFolderMigration.legacyRoots(binds.map { it.first } + dir.path).last().guest
|
||||
var guest = base
|
||||
var n = 2
|
||||
while (guest in taken) guest = "$base-${n++}"
|
||||
SessionPrefs.setGameFolderBinds(context, binds + (dir.path to guest))
|
||||
Log.i(TAG, "games: bound $dir at $guest")
|
||||
}
|
||||
|
||||
private fun listedFolders(context: Context, removed: Set<String>): List<String> {
|
||||
val out = ArrayList<String>()
|
||||
GamesFolderMigration.run(context)
|
||||
|
||||
Reference in new issue
Block a user