Skip to content

Commit 0853c62

Browse files
committed
fix: check if model files exist before returning cached path
1 parent 21df54e commit 0853c62

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

fastembed/common/model_management.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,14 +413,18 @@ def download_model(cls, model: T, cache_dir: str, retries: int = 3, **kwargs: An
413413
try:
414414
cache_kwargs = deepcopy(kwargs)
415415
cache_kwargs["local_files_only"] = True
416-
return Path(
416+
resolved_path = Path(
417417
cls.download_files_from_huggingface(
418418
hf_source,
419419
cache_dir=cache_dir,
420420
extra_patterns=extra_patterns,
421421
**cache_kwargs,
422422
)
423423
)
424+
if (resolved_path / model.model_file).exists() and all(
425+
(resolved_path / file).exists() for file in extra_patterns
426+
):
427+
return resolved_path
424428
except Exception:
425429
pass
426430
finally:

0 commit comments

Comments
 (0)