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:
The412Banner authored and GitHub committed 2026-10-19 19:43:03 +00:00
1 parent aa6fae1924
commit 8e02904a04
2 files changed
+61

No files matched your search

@@ -4,6 +4,7 @@ import android.os.Environment
import com.droiddeck.launcher.session.SessionPrefs
import java.io.File
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Rule
import org.junit.Test
@@ -92,6 +93,50 @@ class AddedExesTest {
assertEquals(0, AddedGames.scan(app).size)
}
@Test fun addingAFolderTheSessionCannotSeeBindsItAndAddsItsGames() {
noGamesFolders()
val games = File(tmp.newFolder("card"), "Winlator/Games")
exe(File(games, "Alpha/Alpha.exe"))
exe(File(games, "Beta/Beta.exe"))
File(games, "steamapps").mkdirs()
assertNull(AddedGames.guestPath(app, games))
val result = AddedGames.addFolder(app, games)
assertEquals(listOf("Alpha", "Beta"), result.added.map { it.name })
assertEquals(listOf(games.path to "${AddedGames.GUEST_DIR}/Games"), SessionPrefs.gameFolderBinds(app))
assertEquals("${AddedGames.GUEST_DIR}/Games/Alpha/Alpha.exe", result.added.first().guestExe)
val again = AddedGames.addFolder(app, games)
assertEquals(0, again.added.size)
assertEquals(2, again.already)
assertEquals(1, SessionPrefs.gameFolderBinds(app).size)
}
@Test fun aSecondFolderWithTheSameNameGetsItsOwnGuestPath() {
noGamesFolders()
val first = File(tmp.newFolder("a"), "Games").apply { exe(File(this, "One/One.exe")) }
val second = File(tmp.newFolder("b"), "Games").apply { exe(File(this, "Two/Two.exe")) }
AddedGames.addFolder(app, first)
AddedGames.addFolder(app, second)
val guests = SessionPrefs.gameFolderBinds(app).map { it.second }
assertEquals(2, guests.toSet().size)
assertEquals("${AddedGames.GUEST_DIR}/Games", guests.first())
}
@Test fun aGuestPathAlreadyTakenIsNeverReused() {
noGamesFolders()
val a = File(tmp.newFolder("a"), "Games").apply { mkdirs() }
val b = File(tmp.newFolder("b"), "Games").apply { mkdirs() }
val c = File(tmp.newFolder("c"), "Games").apply { exe(File(this, "Three/Three.exe")) }
val clash = GamesFolderMigration.legacyRoots(listOf(a.path, b.path, c.path)).last().guest
SessionPrefs.setGameFolderBinds(app, listOf(a.path to "${AddedGames.GUEST_DIR}/Games", b.path to clash))
AddedGames.addFolder(app, c)
val guests = SessionPrefs.gameFolderBinds(app).map { it.second }
assertEquals(3, guests.size)
assertEquals(3, guests.toSet().size)
assertEquals("$clash-2", guests.last())
}
@Test fun aRemovedSingleExeGameStaysOffUntilPickedAgain() {
noGamesFolders()
val pick = onStorage("Download/Celeste/Celeste.exe")