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

Function collect_file

common/hf-cache.cpp:563–612  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

561using migrate_files = std::vector<migrate_file>;
562
563static bool collect_file(const fs::path & old_cache,
564 const std::string & owner,
565 const std::string & repo,
566 const std::string & path,
567 const std::string & sha256,
568 const hf_files & files,
569 migrate_files & to_migrate) {
570
571 const hf_file * file = nullptr;
572
573 for (const auto & f : files) {
574 if (f.path == path) {
575 file = &f;
576 break;
577 }
578 }
579
580 std::string old_filename = make_old_cache_filename(owner, repo, path);
581 fs::path old_path = old_cache / old_filename;
582 fs::path etag_path = old_path.string() + ".etag";
583
584 if (!fs::exists(old_path)) {
585 if (file && fs::exists(file->final_path)) {
586 return true;
587 }
588 LOG_WRN("%s: %s not found in old cache or HF cache\n", __func__, old_filename.c_str());
589 return false;
590 }
591
592 if (!file) {
593 LOG_WRN("%s: %s not found in current repo\n", __func__, old_filename.c_str());
594 return false;
595 }
596
597 if (!sha256.empty() && !file->oid.empty() && sha256 != file->oid) {
598 LOG_WRN("%s: %s is not up to date (sha256 mismatch)\n", __func__, old_filename.c_str());
599 return false;
600 }
601
602 if (file->size > 0) {
603 size_t size = fs::file_size(old_path);
604 if (size != file->size) {
605 LOG_WRN("%s: %s has wrong size %zu (expected %zu)\n", __func__, old_filename.c_str(), size, file->size);
606 return false;
607 }
608 }
609
610 to_migrate.push_back({path, sha256, file->size, old_path, etag_path, file});
611 return true;
612}
613
614static bool collect_files(const fs::path & old_cache,
615 const std::string & owner,

Callers 1

collect_filesFunction · 0.85

Calls 4

make_old_cache_filenameFunction · 0.85
stringMethod · 0.45
emptyMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected