From 0853c62c855412dab2b756aa5f6789089251540c Mon Sep 17 00:00:00 2001 From: George Panchuk Date: Wed, 8 Apr 2026 16:36:23 +0700 Subject: [PATCH] fix: check if model files exist before returning cached path --- fastembed/common/model_management.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fastembed/common/model_management.py b/fastembed/common/model_management.py index bfcf27cec..854f76b75 100644 --- a/fastembed/common/model_management.py +++ b/fastembed/common/model_management.py @@ -413,7 +413,7 @@ def download_model(cls, model: T, cache_dir: str, retries: int = 3, **kwargs: An try: cache_kwargs = deepcopy(kwargs) cache_kwargs["local_files_only"] = True - return Path( + resolved_path = Path( cls.download_files_from_huggingface( hf_source, cache_dir=cache_dir, @@ -421,6 +421,10 @@ def download_model(cls, model: T, cache_dir: str, retries: int = 3, **kwargs: An **cache_kwargs, ) ) + if (resolved_path / model.model_file).exists() and all( + (resolved_path / file).exists() for file in extra_patterns + ): + return resolved_path except Exception: pass finally: