From a4a966990d3956d52719d9224b860efa394b72a6 Mon Sep 17 00:00:00 2001 From: mikemikimike <13286568797@163.com> Date: Thu, 8 Oct 2026 23:40:43 +0800 Subject: [PATCH] fix: avoid scanning cwd during server startup (#2086) --- examples/server/main.cpp | 2 ++ examples/server/runtime.cpp | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/examples/server/main.cpp b/examples/server/main.cpp index 42c84df6..1768f0de 100644 --- a/examples/server/main.cpp +++ b/examples/server/main.cpp @@ -75,6 +75,8 @@ int main(int argc, const char** argv) { } SDSvrParams svr_params; SDContextParams ctx_params; + // Preserve the CLI default while disabling cwd scans for sd-server. + ctx_params.lora_model_dir.clear(); SDGenerationParams default_gen_params; sd_set_log_callback(sd_log_cb, (void*)&svr_params); diff --git a/examples/server/runtime.cpp b/examples/server/runtime.cpp index 3a209313..1a71cf76 100644 --- a/examples/server/runtime.cpp +++ b/examples/server/runtime.cpp @@ -254,6 +254,12 @@ std::string SDSvrParams::to_string() const { void refresh_lora_cache(ServerRuntime& rt) { std::vector new_cache; + if (rt.ctx_params->lora_model_dir.empty()) { + std::lock_guard lock(*rt.lora_mutex); + rt.lora_cache->clear(); + return; + } + fs::path lora_dir = rt.ctx_params->lora_model_dir; std::error_code ec; if (fs::exists(lora_dir, ec) && !ec && fs::is_directory(lora_dir, ec) && !ec) {