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

Function get_cached_files

common/hf-cache.cpp:406–460  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

404}
405
406hf_files get_cached_files(const std::string & repo_id) {
407 fs::path cache_dir = get_cache_directory();
408 if (!fs::exists(cache_dir)) {
409 return {};
410 }
411
412 if (!repo_id.empty() && !is_valid_repo_id(repo_id)) {
413 LOG_WRN("%s: invalid repository: %s\n", __func__, repo_id.c_str());
414 return {};
415 }
416
417 hf_files files;
418
419 for (const auto & repo : fs::directory_iterator(cache_dir)) {
420 if (!repo.is_directory()) {
421 continue;
422 }
423 fs::path snapshots_path = repo.path() / "snapshots";
424
425 if (!fs::exists(snapshots_path)) {
426 continue;
427 }
428 std::string _repo_id = folder_name_to_repo(repo.path().filename().string());
429
430 if (!is_valid_repo_id(_repo_id)) {
431 continue;
432 }
433 if (!repo_id.empty() && _repo_id != repo_id) {
434 continue;
435 }
436 std::string commit = get_cached_ref(repo.path());
437 fs::path commit_path = snapshots_path / commit;
438
439 if (commit.empty() || !fs::is_directory(commit_path)) {
440 continue;
441 }
442 for (const auto & entry : fs::recursive_directory_iterator(commit_path)) {
443 if (!entry.is_regular_file() && !entry.is_symlink()) {
444 continue;
445 }
446 fs::path path = entry.path().lexically_relative(commit_path);
447
448 if (!path.empty()) {
449 hf_file file;
450 file.repo_id = _repo_id;
451 file.path = path.generic_string();
452 file.local_path = entry.path().string();
453 file.final_path = file.local_path;
454 files.push_back(std::move(file));
455 }
456 }
457 }
458
459 return files;
460}
461
462std::string finalize_file(const hf_file & file) {
463 static std::atomic<bool> symlinks_disabled{false};

Callers 2

get_hf_planFunction · 0.85

Calls 7

get_cache_directoryFunction · 0.85
is_valid_repo_idFunction · 0.85
folder_name_to_repoFunction · 0.85
get_cached_refFunction · 0.85
emptyMethod · 0.45
stringMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected