From c1a1c8ee94e37ff7ba2c872e783aaf7f77e0f320 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Gallou=C3=ABt?= Date: Sun, 28 Jun 2026 12:34:11 +0200 Subject: [PATCH] common : allow --offline in llama download (#25091) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Expose the existing --offline flag to `llama download` so a script can run it to check whether a model is already cached and ready to be served without touching the network. Also fix a latent use-after-free in the URL-task on_done callback: first_path is block-scoped and was captured by reference, but invoked after the block ends. Signed-off-by: Adrien Gallouët --- common/arg.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/arg.cpp b/common/arg.cpp index 841ca3ce2..c289ff713 100644 --- a/common/arg.cpp +++ b/common/arg.cpp @@ -467,7 +467,7 @@ void common_models_handler_apply(common_models_handler & handler, common_params // the first part is what gets loaded, so point params.model.path at it if (!url_tasks.empty()) { std::string first_path = url_tasks.front().local_path; - url_tasks.front().on_done = [&]() { params.model.path = first_path; }; + url_tasks.front().on_done = [&, first_path]() { params.model.path = first_path; }; } for (auto & task : url_tasks) { tasks.push_back(std::move(task)); @@ -3471,7 +3471,7 @@ common_params_context common_params_parser_init(common_params & params, llama_ex [](common_params & params) { params.offline = true; } - ).set_env("LLAMA_ARG_OFFLINE")); + ).set_examples({LLAMA_EXAMPLE_COMMON, LLAMA_EXAMPLE_DOWNLOAD}).set_env("LLAMA_ARG_OFFLINE")); add_opt(common_arg( {"-lv", "--verbosity", "--log-verbosity"}, "N", string_format("Set the verbosity threshold. Messages with a higher verbosity will be ignored. Values:\n"