mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 04:46:08 +00:00
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:
1 parent
b424bfa353
commit
56fabbdbf0
2 files changed
+53
-2
No files matched your search
@@ -47,4 +47,52 @@ class GameFileSyncTest {
|
||||
assertFalse(File(folder, "Geometry Wars.steam").exists())
|
||||
assertEquals(0, folder.listFiles()!!.count { it.extension == GameFiles.EXTENSION })
|
||||
}
|
||||
|
||||
@Test fun libraryNotCreatedYetOnPresentStorageIsEmptyNotUnavailable() {
|
||||
val context = RuntimeEnvironment.getApplication()
|
||||
val root = LinuxRuntime.rootDir(context)
|
||||
listOf("usr/bin/gamescope", LinuxRuntime.SESSION_SCRIPT.removePrefix("/"), "opt/android-host/proot", "opt/android-host/loader").forEach { path ->
|
||||
File(root, path).apply { parentFile!!.mkdirs(); writeText("") }
|
||||
}
|
||||
SessionPrefs.setAddedGamesDirs(context, emptyList())
|
||||
File(root, "root/.local/share/Steam/steamapps").mkdirs()
|
||||
val volume = File(context.filesDir, "card").apply { mkdirs() }
|
||||
val library = File(volume, "steam")
|
||||
SessionPrefs.setGameStorage(context, library.path, "Card")
|
||||
val folder = File(context.filesDir, "exports-card").apply { mkdirs() }
|
||||
GameFileSync.enable(context, folder)
|
||||
assertEquals(folder.path, GameFileSync.folder(context))
|
||||
assertFalse(library.exists())
|
||||
library.writeText("")
|
||||
assertThrows(IllegalStateException::class.java) { GameFileSync.syncConfigured(context) }
|
||||
assertTrue(library.delete())
|
||||
GameFileSync.disable(context)
|
||||
}
|
||||
|
||||
@Test fun libraryReadableOnlyWhenListableOrNotCreatedOnPresentParent() {
|
||||
val base = File(RuntimeEnvironment.getApplication().filesDir, "readable").apply { mkdirs() }
|
||||
assertTrue(GameFileSync.libraryReadable(File(base, "dir").apply { mkdirs() }))
|
||||
assertTrue(GameFileSync.libraryReadable(File(base, "missing")))
|
||||
assertFalse(GameFileSync.libraryReadable(File(base, "gone/steam")))
|
||||
assertFalse(GameFileSync.libraryReadable(File(base, "file").apply { writeText("") }))
|
||||
}
|
||||
|
||||
@Test fun previousAutomaticLibraryNotCreatedYetKeepsSyncingButRemovedDriveStops() {
|
||||
val context = RuntimeEnvironment.getApplication()
|
||||
val root = LinuxRuntime.rootDir(context)
|
||||
listOf("usr/bin/gamescope", LinuxRuntime.SESSION_SCRIPT.removePrefix("/"), "opt/android-host/proot", "opt/android-host/loader").forEach { path ->
|
||||
File(root, path).apply { parentFile!!.mkdirs(); writeText("") }
|
||||
}
|
||||
SessionPrefs.setAddedGamesDirs(context, emptyList())
|
||||
SessionPrefs.setGameStorage(context, "", "")
|
||||
File(root, "root/.local/share/Steam/steamapps").mkdirs()
|
||||
val folder = File(context.filesDir, "exports-auto").apply { mkdirs() }
|
||||
val prefs = context.getSharedPreferences("game_files", android.content.Context.MODE_PRIVATE)
|
||||
val volume = File(context.filesDir, "auto-card").apply { mkdirs() }
|
||||
prefs.edit().putString("storageSetting", "").putString("storagePath", File(volume, "steam").path).apply()
|
||||
GameFileSync.enable(context, folder)
|
||||
prefs.edit().putString("storageSetting", "").putString("storagePath", File(context.filesDir, "removed-card/steam").path).apply()
|
||||
assertThrows(IllegalStateException::class.java) { GameFileSync.syncConfigured(context) }
|
||||
GameFileSync.disable(context)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user