From 9dd5e37739cb168ed28f5206fb08a5018de78b74 Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Fri, 27 Nov 2026 01:37:12 -0500 Subject: [PATCH] Keep the session cores when the live file is read while it is being written --- tools/linuxfs/overlay/usr/local/bin/steam-compatibility | 2 +- tools/tests/test_game_cpus_live.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/linuxfs/overlay/usr/local/bin/steam-compatibility b/tools/linuxfs/overlay/usr/local/bin/steam-compatibility index be66f3bc01..cf469efde2 100755 --- a/tools/linuxfs/overlay/usr/local/bin/steam-compatibility +++ b/tools/linuxfs/overlay/usr/local/bin/steam-compatibility @@ -228,7 +228,7 @@ dd_components() { DD_GAME_CPUS_SETUP = """ dd_game_cpus() { local live=/root/.config/droiddeck/game-cores cpus - if [ -f "$live" ] && cpus=$(<"$live") 2>/dev/null; then + if [ -s "$live" ] && cpus=$(<"$live") 2>/dev/null; then [[ -z $cpus || $cpus =~ ^[0-9]+(-[0-9]+)?(,[0-9]+(-[0-9]+)?)*$ ]] || cpus=${DD_GAME_CPUS:-} if [ -z "$cpus" ] && [ -n "${DD_CLIENT_CPUS:-}" ]; then cpus=$(nproc --all 2>/dev/null) && cpus=0-$((cpus - 1)) || cpus= diff --git a/tools/tests/test_game_cpus_live.py b/tools/tests/test_game_cpus_live.py index 90db2c0471..662817183d 100644 --- a/tools/tests/test_game_cpus_live.py +++ b/tools/tests/test_game_cpus_live.py @@ -49,6 +49,9 @@ class LiveGameCpusTest(unittest.TestCase): ["taskset=taskset -c 3,4,5,6,7", "cpus=3,4,5,6,7"]) self.assertEqual(self.run_setup(), ["taskset=", "cpus=unset"]) + def test_a_file_caught_mid_write_keeps_the_session_value(self): + self.assertEqual(self.run_setup("", DD_GAME_CPUS="4,5"), ["taskset=taskset -c 4,5", "cpus=4,5"]) + def test_an_unreadable_value_keeps_the_session_value(self): for bad in ("3;rm\n", "6-\n", "-3\n", "3,,4\n", "3,\n"): self.assertEqual(self.run_setup(bad, DD_GAME_CPUS="4,5"), ["taskset=taskset -c 4,5", "cpus=4,5"], bad)