Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

Fix #3410: a Strata folder in the Trash is not remembered or offered as an install

Niko122173b68dfd8835
diff --git a/setup.py b/setup.py
index fec024004..b39d3c7bc 100644
--- a/setup.py
+++ b/setup.py
@@ -64,6 +64,7 @@ from pathlib import Path
from strata_control import acquisition
from strata_control import draft_layer
+from strata_control.discovery import in_trash
from strata_control import user_args
ROOT = Path(__file__).resolve().parent
@@ -5348,7 +5349,7 @@ def has_data(folder: Path) -> bool:
def other_installs(settings: dict) -> list:
"""Strata folders besides this one that may hold model files: the ones this user ran before, and Strata* folders
next to this one (a zip unpacked again lands in e.g. `Strata-main (1)\\Strata-main`)."""
- cands = [Path(p) for p in settings.get("installs", [])]
+ cands = [Path(p) for p in settings.get("installs", []) if not in_trash(p)]
for base in dict.fromkeys(() if app_settings_file() else (home().parent, home().parent.parent)):
try:
for d in base.iterdir():
@@ -5525,7 +5526,8 @@ def data_folder(requested: str | None, move: bool = False, yes: bool = True, set
warn(f"some model files are still in {folder} (in use, or already in {dest})")
else:
ok(f"model files from {folder} moved to {dest} (a new copy of Strata finds them there)")
- installs = [str(home())] + [p for p in settings.get("installs", []) if p != str(home()) and Path(p).is_dir()]
+ installs = [str(home())] + [p for p in settings.get("installs", [])
+ if p != str(home()) and Path(p).is_dir() and not in_trash(p)]
save_settings({**settings, "data_dir": str(dest), "installs": installs[:20]})
return dest, elsewhere
diff --git a/strata_control/discovery.py b/strata_control/discovery.py
index 6280185cd..964438081 100644
--- a/strata_control/discovery.py
+++ b/strata_control/discovery.py
@@ -96,13 +96,26 @@ def _read_json(path: Path) -> dict:
return data if isinstance(data, dict) else {}
+def in_trash(path: str | os.PathLike) -> bool:
+ """#3410: True when ``path`` is inside a Trash / Recycle Bin folder (a Strata folder that was deleted with the file manager
+ is still a folder there, and was remembered as an install): ~/.local/share/Trash/files/.., /.Trash-1000/.., ~/.Trash/..,
+ $RECYCLE.BIN\\.."""
+ parts = [x.lower() for x in Path(path).parts]
+ for i, x in enumerate(parts):
+ if x in (".trash", "$recycle.bin", "recycler", "$recycle.bin.old") or x.startswith(".trash-"):
+ return True
+ if x == "trash" and i + 1 < len(parts) and parts[i + 1] in ("files", "info", "expunged"):
+ return True # the XDG Trash: ~/.local/share/Trash/files
+ return False
+
+
def _installs_in(settings: dict) -> list[Path]:
items = settings.get("installs")
found: list[Path] = []
for raw in (items if isinstance(items, list) else [])[:20]:
if isinstance(raw, str) and raw:
p = Path(raw).expanduser()
- if p.is_absolute() and p not in found:
+ if p.is_absolute() and p not in found and not in_trash(p):
found.append(p)
return found
diff --git a/tests/terminal/test_issues_022.py b/tests/terminal/test_issues_022.py
index c93f2644e..de5a92088 100644
--- a/tests/terminal/test_issues_022.py
+++ b/tests/terminal/test_issues_022.py
@@ -97,6 +97,37 @@ class Issue3403MacBuildTools(unittest.TestCase):
self.assertIn("S.ensure_build_tools()", inspect.getsource(fn), fn.__name__)
+class Issue3410TrashIsNotAnInstall(unittest.TestCase):
+ def test_trash_folders_are_recognised(self):
+ from strata_control.discovery import in_trash
+ for p in ("/home/u/.local/share/Trash/files/strata", "/mnt/d/.Trash-1000/files/Strata", "/Users/u/.Trash/Strata",
+ "C:\\$Recycle.Bin\\S-1-5-21\\$R123\\Strata", "/home/u/.local/share/trash/files/strata/x"):
+ self.assertTrue(in_trash(p), p)
+ for p in ("/home/u/bin/strata", "/home/u/Trash-talk/strata", "/home/u/trash/strata", "/opt/Strata",
+ "C:\\Users\\u\\Strata"):
+ self.assertFalse(in_trash(p), p)
+
+ def test_remembered_installs_in_the_trash_are_not_listed(self):
+ from strata_control import discovery
+ with tempfile.TemporaryDirectory() as tmp:
+ good = Path(tmp) / "bin" / "strata"
+ trash = Path(tmp) / ".local" / "share" / "Trash" / "files" / "strata"
+ got = discovery._installs_in({"installs": [str(trash), str(good)]})
+ self.assertEqual(got, [good])
+
+ def test_setup_does_not_pass_a_trash_folder_on(self):
+ import setup
+ with tempfile.TemporaryDirectory() as tmp:
+ trash = Path(tmp) / ".local" / "share" / "Trash" / "files" / "strata"
+ trash.mkdir(parents=True)
+ (trash / "setup.py").write_text("x")
+ from unittest import mock
+ nowhere = Path(tmp) / "none" / "none" / "home" # no Strata* folders beside it on this PC
+ with mock.patch.object(setup, "home", return_value=nowhere):
+ self.assertEqual(setup.other_installs({"installs": [str(trash)]}), [])
+ self.assertEqual(setup.other_installs({"installs": [str(trash)] + [str(trash.parent.parent)]}), [])
+
+
class Issue2971WebToolRowFitsPhones(unittest.TestCase):
"""A tool row widened the whole page on a phone (752 px page at a 412 px viewport, measured in Chrome). The three rules
that keep it inside the viewport; a long tool name is cut with an ellipsis instead of pushing the page."""