server: simplify get_info result handling

Drop the named limits and the working directory error branch, keeping
the probe result handling to a single expression.
This commit is contained in:
Pascal
2026-08-03 18:22:56 +02:00
parent c74747ce8f
commit 3dfb7c7fad
+2 -8
View File
@@ -1094,9 +1094,6 @@ struct server_tool_get_datetime : server_tool {
// get_info: returns runtime info (OS name/version and cwd)
//
static constexpr size_t SERVER_TOOL_GET_INFO_MAX_OUTPUT = 4 * 1024; // 4 KB
static constexpr int SERVER_TOOL_GET_INFO_TIMEOUT = 5; // seconds
struct server_tool_get_info : server_tool {
server_tool_get_info() {
name = "get_info";
@@ -1122,9 +1119,9 @@ struct server_tool_get_info : server_tool {
auto io = make_tools_io(params);
#ifdef _WIN32
auto res = io->run({"cmd", "/c", "ver"}, SERVER_TOOL_GET_INFO_MAX_OUTPUT, SERVER_TOOL_GET_INFO_TIMEOUT);
auto res = io->run({"cmd", "/c", "ver"}, 4096, 5);
#else
auto res = io->run({"uname", "-a"}, SERVER_TOOL_GET_INFO_MAX_OUTPUT, SERVER_TOOL_GET_INFO_TIMEOUT);
auto res = io->run({"uname", "-a"}, 4096, 5);
#endif
// "ver" prints a blank line before the version, so the output is stripped on both ends;
// a failed spawn or a timeout leaves a diagnostic in res.output, which is not an OS name
@@ -1134,9 +1131,6 @@ struct server_tool_get_info : server_tool {
if (cwd.empty()) {
std::error_code ec;
cwd = fs::current_path(ec).string();
if (ec) {
cwd = "unknown";
}
}
return {