fix(desktop): Downloads, Documents and game folder links work again without proot (#3273)

Links made in a proot session store the guest path as their target, which the
kernel cannot follow in the middle of a path once the session runs without
proot: the folders listed, but nothing inside them could be opened or created.
The desktop setup now makes a link again when it cannot be walked into, so it
is stored in the form the current mode follows.
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-11-26 10:30:28 -05:00
1 parent dbfcd764f3
commit dcb1a3001b
4 files changed
+83 -2

No files matched your search

@@ -115,7 +115,7 @@ def link_libraries():
common = os.path.join(library, "steamapps", "common")
link = os.path.join(HOME, label)
if os.path.isdir(common):
if os.path.islink(link) and os.readlink(link) == common:
if os.path.islink(link) and os.readlink(link) == common and os.path.isdir(os.path.join(link, ".")):
continue
if os.path.islink(link) or os.path.isfile(link):
os.unlink(link)
@@ -10,7 +10,7 @@ free_name() {
share() {
local android=$HOME/Storage/$1 link=$HOME/$2 f
[ -d "$android" ] && [ -w "$android" ] || return 0
[ "$(readlink "$link" 2>/dev/null)" = "$android" ] && return 0
[ "$(readlink "$link" 2>/dev/null)" = "$android" ] && [ -d "$link/." ] && return 0
if [ -L "$link" ]; then
rm -f "$link"
elif [ -d "$link" ]; then
+59
View File
@@ -0,0 +1,59 @@
import os
import subprocess
import tempfile
import unittest
from pathlib import Path
SCRIPT = Path(__file__).resolve().parents[1] / "linuxfs/overlay/usr/local/bin/droiddeck-downloads"
class DesktopDownloadsTest(unittest.TestCase):
def run_script(self, home, shim=None):
env = dict(os.environ, HOME=str(home))
if shim:
env["PATH"] = f"{shim}:{env['PATH']}"
subprocess.run(["bash", str(SCRIPT)], env=env, check=True)
def make_home(self, temp):
home = Path(temp) / "home"
for name in ("Download", "Documents"):
(home / "Storage" / name).mkdir(parents=True)
return home
def test_links_to_the_android_folders_are_made(self):
with tempfile.TemporaryDirectory() as temp:
home = self.make_home(temp)
self.run_script(home)
self.assertEqual(str(home / "Storage/Download"), os.readlink(home / "Downloads"))
self.assertEqual(str(home / "Storage/Documents"), os.readlink(home / "Documents"))
def test_working_links_are_kept(self):
with tempfile.TemporaryDirectory() as temp:
home = self.make_home(temp)
self.run_script(home)
before = os.lstat(home / "Downloads").st_ino
self.run_script(home)
self.assertEqual(before, os.lstat(home / "Downloads").st_ino)
def test_links_that_name_the_folder_but_cannot_be_walked_are_made_again(self):
with tempfile.TemporaryDirectory() as temp:
home = self.make_home(temp)
for link in ("Downloads", "Documents"):
os.symlink(str(Path(temp) / "gone"), home / link)
shim = Path(temp) / "bin"
shim.mkdir()
(shim / "readlink").write_text(
'#!/bin/bash\ncase "${@: -1}" in\n'
f' "{home}/Downloads") echo "{home}/Storage/Download" ;;\n'
f' "{home}/Documents") echo "{home}/Storage/Documents" ;;\n'
' *) exec /usr/bin/readlink "$@" ;;\nesac\n')
(shim / "readlink").chmod(0o755)
self.run_script(home, shim)
for link, folder in (("Downloads", "Download"), ("Documents", "Documents")):
self.assertEqual(str(home / "Storage" / folder), os.readlink(home / link))
self.assertTrue((home / link / ".").is_dir())
self.assertEqual([], sorted(p.name for p in home.iterdir() if ".old." in p.name))
if __name__ == "__main__":
unittest.main()
+22
View File
@@ -150,6 +150,28 @@ class CompatLibrariesTest(unittest.TestCase):
class DesktopGamesTest(unittest.TestCase):
def test_library_links_that_cannot_be_walked_are_made_again(self):
with tempfile.TemporaryDirectory() as temp:
root = Path(temp)
steam, home = root / "Steam", root / "home"
(steam / "steamapps/common/Game").mkdir(parents=True)
home.mkdir()
common = str(steam / "steamapps/common")
stale, kept = home / "Steam Games", home / "SD Games"
os.symlink(str(root / "elsewhere"), stale)
card = root / "card/steamapps/common"
card.mkdir(parents=True)
os.symlink(str(card), kept)
before = os.lstat(kept).st_ino
real = os.readlink
with patch.object(desktop, "HOME", str(home)), \
patch.object(desktop, "LIBRARIES", ((str(steam), "Steam Games"), (str(root / "card"), "SD Games"))), \
patch.object(desktop.os, "readlink", lambda p: common if p == str(stale) else real(p)):
desktop.link_libraries()
self.assertEqual(common, os.readlink(stale))
self.assertTrue((stale / "Game").is_dir())
self.assertEqual(before, os.lstat(kept).st_ino)
def test_games_in_registered_libraries_get_entries(self):
with tempfile.TemporaryDirectory() as temp:
root = Path(temp)