MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / get_cached_ref

Function get_cached_ref

common/hf-cache.cpp:376–404  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

374}
375
376static std::string get_cached_ref(const fs::path & repo_path) {
377 fs::path refs_path = repo_path / "refs";
378 if (!fs::is_directory(refs_path)) {
379 return {};
380 }
381 std::string fallback;
382
383 for (const auto & entry : fs::directory_iterator(refs_path)) {
384 if (!entry.is_regular_file()) {
385 continue;
386 }
387 std::ifstream f(entry.path());
388 std::string commit;
389 if (!f || !std::getline(f, commit) || commit.empty()) {
390 continue;
391 }
392 if (!is_valid_commit(commit)) {
393 LOG_WRN("%s: skip invalid commit: %s\n", __func__, commit.c_str());
394 continue;
395 }
396 if (entry.path().filename() == "main") {
397 return commit;
398 }
399 if (fallback.empty()) {
400 fallback = commit;
401 }
402 }
403 return fallback;
404}
405
406hf_files get_cached_files(const std::string & repo_id) {
407 fs::path cache_dir = get_cache_directory();

Callers 1

get_cached_filesFunction · 0.85

Calls 2

is_valid_commitFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected