ggml : simplify backend search path error handling (#28367)

Signed-off-by: Adrien Gallouët <angt@huggingface.co>
This commit is contained in:
Adrien Gallouët authored and GitHub committed 2026-10-13 21:22:19 +03:00
1 parent d71e324a44
commit 1b70350c92
1 file changed
+7 -14
+7 -14
View File
@@ -493,7 +493,7 @@ static ggml_backend_reg_t ggml_backend_load_best(const char * name, bool silent,
std::error_code cwd_ec;
const fs::path cwd = fs::current_path(cwd_ec);
if (cwd_ec) {
GGML_LOG_DEBUG("%s: current_path() failure, error-message: %s\n", __func__, cwd_ec.message().c_str());
GGML_LOG_DEBUG("%s: failed to get current directory: %s\n", __func__, cwd_ec.message().c_str());
} else {
search_paths.push_back(cwd);
}
@@ -506,20 +506,9 @@ static ggml_backend_reg_t ggml_backend_load_best(const char * name, bool silent,
std::error_code ec;
for (const auto & search_path : search_paths) {
if (!fs::exists(search_path, ec)) {
if (ec) {
GGML_LOG_DEBUG("%s: posix_stat(%s) failure, error-message: %s\n", __func__, path_str(search_path).c_str(), ec.message().c_str());
} else {
GGML_LOG_DEBUG("%s: search path %s does not exist\n", __func__, path_str(search_path).c_str());
}
continue;
}
std::error_code dir_ec;
fs::directory_iterator dir_it(search_path, fs::directory_options::skip_permission_denied, dir_ec);
if (dir_ec) {
GGML_LOG_DEBUG("%s: failed to enumerate %s: %s\n", __func__, path_str(search_path).c_str(), dir_ec.message().c_str());
continue;
}
fs::directory_iterator dir_it(search_path, dir_ec);
for (const fs::directory_iterator end; dir_it != end; dir_it.increment(dir_ec)) {
const auto & entry = *dir_it;
if (entry.is_regular_file(ec)) {
@@ -550,6 +539,10 @@ static ggml_backend_reg_t ggml_backend_load_best(const char * name, bool silent,
}
}
}
if (dir_ec) {
GGML_LOG_DEBUG("%s: failed to enumerate %s: %s\n", __func__, path_str(search_path).c_str(), dir_ec.message().c_str());
}
}
if (best_score == 0) {