common : fix duplicated file name with hf_repo and hf_file (#10550)

This commit is contained in:
Xuan Son Nguyen 2024-11-27 22:30:52 +01:00 committed by GitHub
parent 3ad5451f3b
commit 9f912511bc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 43 additions and 31 deletions

View file

@ -128,7 +128,11 @@ static void common_params_handle_model_default(common_params & params) {
}
params.hf_file = params.model;
} else if (params.model.empty()) {
params.model = fs_get_cache_file(string_split<std::string>(params.hf_file, '/').back());
// this is to avoid different repo having same file name, or same file name in different subdirs
std::string filename = params.hf_repo + "_" + params.hf_file;
// to make sure we don't have any slashes in the filename
string_replace_all(filename, "/", "_");
params.model = fs_get_cache_file(filename);
}
} else if (!params.model_url.empty()) {
if (params.model.empty()) {