Commit 102a464b authored by Your Name's avatar Your Name

Fix cached model path lookup to match download format

The cache filename format was inconsistent:
- get_cached_model_path used: {hash}{ext}
- load_model download used: {hash}_{filename}

This caused cache lookups to always fail. Now both use {hash}_{filename}
format to ensure cached models are properly found.
parent c72d8384
...@@ -49,8 +49,11 @@ def get_cached_model_path(url: str) -> Optional[str]: ...@@ -49,8 +49,11 @@ def get_cached_model_path(url: str) -> Optional[str]:
# Create a safe filename from the URL using SHA-256 hash # Create a safe filename from the URL using SHA-256 hash
url_hash = hashlib.sha256(url.encode()).hexdigest() url_hash = hashlib.sha256(url.encode()).hexdigest()
url_path = url.split('?')[0] # Remove query params url_path = url.split('?')[0] # Remove query params
ext = os.path.splitext(url_path)[1] or '.gguf' filename = os.path.basename(url_path)
cached_filename = f"{url_hash}{ext}" if not filename:
filename = "model.gguf"
# Match the format used in load_model: {hash}_{filename}
cached_filename = f"{url_hash}_{filename}"
cached_path = os.path.join(cache_dir, cached_filename) cached_path = os.path.join(cache_dir, cached_filename)
if os.path.exists(cached_path): if os.path.exists(cached_path):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment