From: Adrien Gallouët Date: Sun, 28 Jun 2026 10:34:11 +0000 (+0200) Subject: common : allow --offline in llama download (#25091) X-Git-Tag: upstream/0.0.10438~608 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=c1a1c8ee94e37ff7ba2c872e783aaf7f77e0f320;p=pkg%2Fggml%2Fsources%2Fllama.cpp common : allow --offline in llama download (#25091) 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 --- 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"