From 14238b8d62f11e4bde22b340fa195cdd57bb5864 Mon Sep 17 00:00:00 2001 From: Will Miao <13051207myq@gmail.com> Date: Wed, 11 Jun 2025 15:43:12 +0800 Subject: [PATCH] Update preview URL handling in load_metadata function to reflect model location changes. See #113 --- py/utils/file_utils.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/py/utils/file_utils.py b/py/utils/file_utils.py index 86ebf089..7372e229 100644 --- a/py/utils/file_utils.py +++ b/py/utils/file_utils.py @@ -207,11 +207,11 @@ async def load_metadata(file_path: str, model_class: Type[BaseModelMetadata] = L data['preview_url'] = new_preview_url needs_update = True else: - # Compare preview paths without extensions - stored_preview_base = os.path.splitext(preview_url)[0] - current_preview_base = os.path.splitext(normalize_path(preview_url))[0] - if stored_preview_base != current_preview_base: - data['preview_url'] = normalize_path(preview_url) + if stored_path_base != current_path_base: + # If model location changed, update preview path by replacing old path with new path + preview_file = os.path.basename(preview_url) + new_preview_url = os.path.join(os.path.dirname(file_path), preview_file) + data['preview_url'] = normalize_path(new_preview_url) needs_update = True # Ensure all fields are present