From 0c5d787c4fc2a9809a5deaec9be7a5f44a80a867 Mon Sep 17 00:00:00 2001 From: "marc.bate" Date: Mon, 8 Jun 2026 19:04:55 -0500 Subject: [PATCH] fix: handle cross-drive paths in get_info_file on Windows os.path.relpath raises ValueError when file_path and base_dir are on different Windows drive letters (e.g. model on M: but default folder on C:). Iterate all registered folder paths for the model type and use the first one that shares a drive with the file, falling back to filename- only when no candidate matches. Fixes: ValueError: path is on mount 'M:', start on mount 'C:' --- utility/rgthree_api/utils_info.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/utility/rgthree_api/utils_info.py b/utility/rgthree_api/utils_info.py index 9196a40..8c832f4 100644 --- a/utility/rgthree_api/utils_info.py +++ b/utility/rgthree_api/utils_info.py @@ -54,12 +54,29 @@ def get_info_file(file_path: str, model_type: str, force=False): """ Returns the path to the info file. Saves JSON files with lora name in _power_preview folder inside the model_type folder. """ - base_dir = folder_paths.get_folder_paths(model_type)[0] + # Find the base dir that actually contains file_path. On Windows, os.path.relpath raises + # ValueError when path and start are on different drive letters (e.g. C: vs M:), so we + # iterate all registered folders and skip cross-drive candidates. + base_dir = None + relative_path = None + for candidate in folder_paths.get_folder_paths(model_type): + try: + rel = os.path.relpath(file_path, candidate) + if not rel.startswith('..'): + base_dir = candidate + relative_path = rel + break + except ValueError: + continue + + if base_dir is None: + # Fallback: no candidate shares a drive with file_path; use first dir and filename only. + base_dir = folder_paths.get_folder_paths(model_type)[0] + relative_path = os.path.basename(file_path) # Create a mirrored folder structure in loras/_power_preview power_preview_dir = os.path.join(base_dir, '_power_preview') - relative_path = os.path.relpath(file_path, base_dir) # Get the filename without extension and change to .json filename_without_ext = os.path.splitext(os.path.basename(relative_path))[0] relative_dir = os.path.dirname(relative_path)