Keep the session cores when the live file is read while it is being written

This commit is contained in:
maxjivi05 committed 2026-11-27 01:37:12 -05:00
1 parent 9077704379
commit 9dd5e37739
2 files changed
+4 -1

No files matched your search

@@ -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=
+3
View File
@@ -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)