\brief Check if the model is downloaded \param model_tag the model tag \return true if the model is downloaded, false otherwise
| 21 | /// \param model_tag the model tag |
| 22 | /// \return true if the model is downloaded, false otherwise |
| 23 | bool ModelDownloader::is_model_downloaded(const std::string& model_tag, bool sub_process_mode, bool fast_check) { |
| 24 | auto missing_files = get_missing_files(model_tag); |
| 25 | bool is_config_file_missing = std::find(missing_files.begin(), missing_files.end(), "config.json") != missing_files.end(); |
| 26 | if (!is_config_file_missing) { |
| 27 | if (!check_model_compatibility(model_tag, sub_process_mode)) { |
| 28 | if (!sub_process_mode) |
| 29 | header_print("FLM", "Model " + model_tag + " is not compatible with the current FLM version. "); |
| 30 | // Fast path: skip the expensive HF metadata fetch + per-file hash |
| 31 | // verification. Caller (e.g. `flm list`) only needs the boolean |
| 32 | // status; cleanup can happen later on `pull` / `check`. |
| 33 | if (fast_check) { |
| 34 | return false; |
| 35 | } |
| 36 | // Instead of removing all files wholesale, verify each file against |
| 37 | // HuggingFace metadata and remove only corrupted ones (same logic |
| 38 | // as check_model). Files that pass verification can be reused. |
| 39 | verify_and_clean_files(model_tag, sub_process_mode); |
| 40 | return false; |
| 41 | } |
| 42 | } |
| 43 | return missing_files.empty(); |
| 44 | } |
| 45 | |
| 46 | /// \brief Check if the model is compatible with the current FLM version |
| 47 | /// \param model_tag the model tag |
no test coverage detected