fix(recipes): allow recipes storage path on a different drive (Windows)

os.path.commonpath raises ValueError for paths on different Windows
drives. Treat that as no common root so cross-drive recipes migrations
succeed instead of failing with 'Invalid recipes path change'.
This commit is contained in:
Will Miao
2026-08-06 22:18:24 +08:00
parent 7df83f44b8
commit 0f11b6def9
2 changed files with 58 additions and 3 deletions

View File

@@ -1473,10 +1473,12 @@ class SettingsManager:
try:
common_root = os.path.commonpath([source, target])
except ValueError as exc:
raise ValueError("Invalid recipes path change") from exc
except ValueError:
# Windows: paths on different drives share no common root.
# A cross-drive move is valid, so treat it as no common root.
common_root = None
if common_root == source:
if common_root is not None and common_root == source:
raise ValueError("Recipes path cannot be moved into a nested directory")
planned_recipe_updates: Dict[str, Dict[str, Any]] = {}