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

Function finalize_file

common/hf-cache.cpp:462–503  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

460}
461
462std::string finalize_file(const hf_file & file) {
463 static std::atomic<bool> symlinks_disabled{false};
464
465 std::error_code ec;
466 fs::path local_path(file.local_path);
467 fs::path final_path(file.final_path);
468
469 if (local_path == final_path || fs::exists(final_path, ec)) {
470 return file.final_path;
471 }
472
473 if (!fs::exists(local_path, ec)) {
474 return file.final_path;
475 }
476
477 fs::create_directories(final_path.parent_path(), ec);
478
479 if (!symlinks_disabled) {
480 fs::path target = fs::relative(local_path, final_path.parent_path(), ec);
481 if (!ec) {
482 fs::create_symlink(target, final_path, ec);
483 }
484 if (!ec) {
485 return file.final_path;
486 }
487 }
488
489 if (!symlinks_disabled.exchange(true)) {
490 LOG_WRN("%s: failed to create symlink: %s\n", __func__, ec.message().c_str());
491 LOG_WRN("%s: switching to degraded mode\n", __func__);
492 }
493
494 fs::rename(local_path, final_path, ec);
495 if (ec) {
496 LOG_WRN("%s: failed to move file to snapshots: %s\n", __func__, ec.message().c_str());
497 fs::copy(local_path, final_path, ec);
498 if (ec) {
499 LOG_ERR("%s: failed to copy file to snapshots: %s\n", __func__, ec.message().c_str());
500 }
501 }
502 return file.final_path;
503}
504
505// delete everything after this line, one day
506

Callers 2

common_download_modelFunction · 0.85
migrate_fileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected