mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-25 07:46:01 +00:00
fix(battlenet): games installed inside the runtime stay listed after a native session (#3148)
* fix(battlenet): games installed inside the runtime stay listed after a native session * test(battlenet): expect the shared folder for a lone Forever install --------- Co-authored-by: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com> Co-authored-by: maxjivi05 <maxjividen@gmail.com>
This commit is contained in:
4 files changed
+87
-2
No files matched your search
@@ -299,6 +299,27 @@ def map_drive(root, volume):
|
||||
return None
|
||||
|
||||
|
||||
def rootfs():
|
||||
host = os.environ.get("DDNATV_ROOT")
|
||||
return os.path.realpath(host) if host else None
|
||||
|
||||
|
||||
def guest_path(path):
|
||||
host = rootfs()
|
||||
if not host or not inside(path, host):
|
||||
return None
|
||||
return "/" + path[len(host):].strip("/")
|
||||
|
||||
|
||||
def rootfs_drive(root, text):
|
||||
found = re.match(r"(?i)^([abd-y]):[\\/]", text)
|
||||
host = rootfs()
|
||||
if not found or not host:
|
||||
return False
|
||||
link = os.path.join(dosdevices(root), found.group(1).lower() + ":")
|
||||
return os.path.islink(link) and inside(host, os.path.realpath(link))
|
||||
|
||||
|
||||
def install_path(root, library):
|
||||
library = library.rstrip("/") or "/"
|
||||
try:
|
||||
@@ -308,6 +329,9 @@ def install_path(root, library):
|
||||
return "Z:" + library
|
||||
if volume == "/":
|
||||
return "Z:" + library
|
||||
host = rootfs()
|
||||
if host and inside(host, volume):
|
||||
return "Z:" + (guest_path(path) or library)
|
||||
drive = mapped_drive(root, path, volume)
|
||||
if drive is None and not wine_processes(os.path.join(prefix(root), "pfx")):
|
||||
drive = map_drive(root, volume)
|
||||
@@ -586,11 +610,15 @@ def drive_folder(root, value):
|
||||
text = value.decode("utf-8")
|
||||
except UnicodeDecodeError:
|
||||
return value
|
||||
if not re.match(r"(?i)^z:[\\/]", text):
|
||||
holds_root = rootfs_drive(root, text)
|
||||
if not holds_root and not re.match(r"(?i)^z:[\\/]", text):
|
||||
return value
|
||||
folder = windows_path(root, text)
|
||||
if not folder or not os.path.isdir(folder):
|
||||
return value
|
||||
if holds_root:
|
||||
guest = guest_path(os.path.realpath(folder))
|
||||
return value if guest is None else ("Z:" + guest).encode("utf-8")
|
||||
moved = install_path(root, folder)
|
||||
return value if moved.startswith("Z:") else moved.replace("\\", "/").encode("utf-8")
|
||||
|
||||
@@ -725,7 +753,7 @@ def configure(root, library=None):
|
||||
return
|
||||
try:
|
||||
if move_installs(root):
|
||||
say("Battle.net's installed games on a mapped volume now use its Wine drive")
|
||||
say("Battle.net's installed games now use the Wine drive of their volume")
|
||||
except OSError as error:
|
||||
say("Battle.net's installed games not moved to their Wine drive: %s" % error)
|
||||
try:
|
||||
|
||||
@@ -376,6 +376,38 @@ class DriveTest(Temp):
|
||||
self.assertEqual(os.readlink(self.devices / "d:"), str(self.card))
|
||||
self.assertFalse(BNET["move_installs"](self.root))
|
||||
|
||||
def test_the_volume_holding_the_native_rootfs_gets_no_drive(self):
|
||||
rootfs = self.card / "files/linuxfs"
|
||||
library = rootfs / "root/Games/Stores/Battle.net"
|
||||
library.mkdir(parents=True)
|
||||
with mock.patch.dict(os.environ, {"DDNATV_ROOT": str(rootfs)}):
|
||||
self.assertEqual(BNET["install_path"](self.root, str(library)), "Z:/root/Games/Stores/Battle.net")
|
||||
self.assertEqual(BNET["install_path"](self.root, str(self.library)), "Z:" + str(self.library))
|
||||
self.assertFalse(self.devices.exists())
|
||||
self.assertEqual(BNET["install_path"](self.root, str(self.library)), "D:\\Games\\Battle.net")
|
||||
|
||||
def test_games_moved_to_a_drive_holding_the_native_rootfs_go_back_to_the_root_drive(self):
|
||||
rootfs = self.card / "files/linuxfs"
|
||||
game = rootfs / "root/Games/Stores/Battle.net/World of Warcraft"
|
||||
game.mkdir(parents=True)
|
||||
card = self.tmp / "sd"
|
||||
(card / "Diablo").mkdir(parents=True)
|
||||
self.devices.mkdir(parents=True)
|
||||
os.symlink(str(self.card), self.devices / "d:")
|
||||
os.symlink(str(card), self.devices / "e:")
|
||||
client = self.product("battle.net", "C:/Program Files (x86)/Battle.net")
|
||||
sd = self.product("d3", "E:/Diablo")
|
||||
gone = self.product("gone", "D:/files/linuxfs/root/Games/Missing")
|
||||
path = self.database(client, self.product("wowf", "D:/files/linuxfs/root/Games/Stores/Battle.net/World of Warcraft"), sd, gone)
|
||||
before = path.read_bytes()
|
||||
self.assertFalse(BNET["move_installs"](self.root))
|
||||
self.assertEqual(path.read_bytes(), before)
|
||||
with mock.patch.dict(os.environ, {"DDNATV_ROOT": str(rootfs)}):
|
||||
self.assertTrue(BNET["move_installs"](self.root))
|
||||
self.assertEqual(path.read_bytes(), client + self.product("wowf", "Z:/root/Games/Stores/Battle.net/World of Warcraft")
|
||||
+ sd + gone + self.field(7, b"tail"))
|
||||
self.assertFalse(BNET["move_installs"](self.root))
|
||||
|
||||
def test_registrations_stay_while_the_prefix_runs_or_the_database_is_unreadable(self):
|
||||
game = self.library / "World of Warcraft"
|
||||
game.mkdir()
|
||||
|
||||
Reference in new issue
Block a user