url: tweak sig of fs_get_cache_file
This commit is contained in:
parent
bc5acfd124
commit
76612a27be
2 changed files with 6 additions and 5 deletions
|
@ -200,13 +200,13 @@ void gpt_params_handle_model_default(gpt_params & params) {
|
||||||
}
|
}
|
||||||
params.hf_file = params.model;
|
params.hf_file = params.model;
|
||||||
} else if (params.model.empty()) {
|
} else if (params.model.empty()) {
|
||||||
params.model = fs_get_cache_file_path(params.hf_file);
|
params.model = fs_get_cache_file(string_split(params.hf_file, '/').back());
|
||||||
}
|
}
|
||||||
} else if (!params.model_url.empty()) {
|
} else if (!params.model_url.empty()) {
|
||||||
if (params.model.empty()) {
|
if (params.model.empty()) {
|
||||||
auto f = string_split(params.model_url, '#').front();
|
auto f = string_split(params.model_url, '#').front();
|
||||||
f = string_split(f, '?').front();
|
f = string_split(f, '?').front();
|
||||||
params.model = fs_get_cache_file_path(f);
|
params.model = fs_get_cache_file(string_split(f, '/').back());
|
||||||
}
|
}
|
||||||
} else if (params.model.empty()) {
|
} else if (params.model.empty()) {
|
||||||
params.model = DEFAULT_MODEL_PATH;
|
params.model = DEFAULT_MODEL_PATH;
|
||||||
|
@ -2273,13 +2273,14 @@ std::string fs_get_cache_directory() {
|
||||||
return ensure_trailing_slash(cache_directory);
|
return ensure_trailing_slash(cache_directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string fs_get_cache_file_path(const std::string & path) {
|
std::string fs_get_cache_file(const std::string & filename) {
|
||||||
|
GGML_ASSERT(filename.find(DIRECTORY_SEPARATOR) == std::string::npos);
|
||||||
std::string cache_directory = fs_get_cache_directory();
|
std::string cache_directory = fs_get_cache_directory();
|
||||||
const bool success = fs_create_directory_with_parents(cache_directory);
|
const bool success = fs_create_directory_with_parents(cache_directory);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
throw std::runtime_error("failed to create cache directory: " + cache_directory);
|
throw std::runtime_error("failed to create cache directory: " + cache_directory);
|
||||||
}
|
}
|
||||||
return cache_directory + string_split(path, '/').back();
|
return cache_directory + filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -277,7 +277,7 @@ bool fs_validate_filename(const std::string & filename);
|
||||||
bool fs_create_directory_with_parents(const std::string & path);
|
bool fs_create_directory_with_parents(const std::string & path);
|
||||||
|
|
||||||
std::string fs_get_cache_directory();
|
std::string fs_get_cache_directory();
|
||||||
std::string fs_get_cache_file_path(const std::string & path);
|
std::string fs_get_cache_file(const std::string & filename);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Model utils
|
// Model utils
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue