fix(battlenet): an install folder chosen in Battle.net on the library's drive is kept (#3479)

* fix(battlenet): an install folder chosen in Battle.net on the library's drive is kept

Every open set Battle.net's default install folder back to the library folder whenever the two differed, so a folder the user picked in Battle.net on the same drive was replaced on the next open. The folder is now only moved to the library when it is unset, missing, or on another drive.

* fix(battlenet): check the trimmed folder against the rootfs drives
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-11-30 14:24:05 -05:00
1 parent 54ca518553
commit 7404fba5a3
2 files changed
+43

No files matched your search

@@ -350,6 +350,17 @@ def keeps_open(root):
return isinstance(client, dict) and LAUNCH_BEHAVIOR[0] in client and client[LAUNCH_BEHAVIOR[0]] != LAUNCH_BEHAVIOR[1]
def chosen_folder(root, current, library):
current = current.strip()
folder = windows_path(root, current) if current else None
if not folder or rootfs_drive(root, current) or not os.path.isdir(folder):
return False
try:
return volume_root(os.path.realpath(folder)) == volume_root(os.path.realpath(library))
except OSError:
return False
def write_config(root, library=None):
path = os.path.join(drive_c(root), *CONFIG)
key, value = LAUNCH_BEHAVIOR
@@ -374,6 +385,7 @@ def write_config(root, library=None):
client["HardwareAcceleration"] = "false"
changes.append("acceleration")
if library and isinstance(client.setdefault("Install", {}), dict) \
and not chosen_folder(root, str(client["Install"].get("DefaultInstallPath", "")), library) \
and str(client["Install"].get("DefaultInstallPath", "")).rstrip("/\\") != install_path(root, library).rstrip("\\"):
client["Install"]["DefaultInstallPath"] = install_path(root, library)
changes.append("library")
+31
View File
@@ -295,6 +295,37 @@ class DriveTest(Temp):
self.assertEqual(BNET["install_path"](self.root, str(self.card)), "D:\\")
self.assertEqual(sorted(os.listdir(self.devices)), ["d:"])
def test_a_folder_chosen_in_battlenet_on_the_library_drive_is_kept(self):
path = Path(BNET["drive_c"](self.root)).joinpath(*BNET["CONFIG"])
BNET["write_config"](self.root)
self.assertEqual(BNET["write_config"](self.root, str(self.library)), "library")
(self.card / "Battle.net").mkdir()
config = json.loads(path.read_text())
config["Client"]["Install"]["DefaultInstallPath"] = "D:\\Battle.net"
path.write_text(json.dumps(config))
self.assertIsNone(BNET["write_config"](self.root, str(self.library)))
self.assertEqual(json.loads(path.read_text())["Client"]["Install"]["DefaultInstallPath"], "D:\\Battle.net")
def test_a_chosen_folder_inside_the_native_rootfs_is_not_kept_whatever_its_spacing(self):
BNET["write_config"](self.root, str(self.library))
rootfs = self.card / "files/linuxfs"
(rootfs / "Games").mkdir(parents=True)
with mock.patch.dict(os.environ, {"DDNATV_ROOT": str(rootfs)}):
for current in ("D:\\files\\linuxfs\\Games", " D:\\files\\linuxfs\\Games"):
self.assertFalse(BNET["chosen_folder"](self.root, current, str(self.library)))
def test_a_folder_on_another_drive_or_missing_moves_to_the_library(self):
path = Path(BNET["drive_c"](self.root)).joinpath(*BNET["CONFIG"])
BNET["write_config"](self.root, str(self.library))
internal = self.tmp / "root/Games/Stores/Battle.net"
internal.mkdir(parents=True)
for current in ("Z:" + str(internal), "D:\\Gone"):
config = json.loads(path.read_text())
config["Client"]["Install"]["DefaultInstallPath"] = current
path.write_text(json.dumps(config))
self.assertEqual(BNET["write_config"](self.root, str(self.library)), "library")
self.assertEqual(json.loads(path.read_text())["Client"]["Install"]["DefaultInstallPath"], "D:\\Games\\Battle.net")
def test_drives_in_use_and_the_ones_proton_owns_are_left_alone(self):
self.devices.mkdir(parents=True)
os.symlink("/somewhere/else", self.devices / "d:")