From ebacc9f1956e6bcb1519ae1439975d48df04e663 Mon Sep 17 00:00:00 2001 From: George Panchuk Date: Wed, 7 Oct 2026 15:30:02 +0700 Subject: [PATCH] fix: show progress bars when downloading new or corrupted model files --- fastembed/common/model_management.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/fastembed/common/model_management.py b/fastembed/common/model_management.py index fcc04b87..583bef5a 100644 --- a/fastembed/common/model_management.py +++ b/fastembed/common/model_management.py @@ -402,11 +402,17 @@ def _save_file_metadata(model_dir: Path, meta: dict[str, dict[str, int | str]]) verified_metadata = False - if snapshot_dir.exists() and metadata_file.exists(): + # a forced download re-fetches every file, so show progress and re-collect the metadata + if not kwargs.get("force_download") and snapshot_dir.exists() and metadata_file.exists(): metadata = json.loads(metadata_file.read_text()) + # metadata lacking a requested file, e.g. a new model_file, can't vouch for it + requested_files = {f.path for f in repo_files if f.path in allow_patterns} + stored_files = {_repo_relative_path(Path(rel_path)) for rel_path in metadata} # empty metadata lists no files, so it can't vouch for the cached ones - verified_metadata = bool(metadata) and _verify_files_from_metadata( - snapshot_dir, metadata, repo_files + verified_metadata = ( + bool(metadata) + and requested_files.issubset(stored_files) + and _verify_files_from_metadata(snapshot_dir, metadata, repo_files) ) if verified_metadata: