Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 257573b

Browse files
authored
fix: handle path with space (#1963)
1 parent eb28d51 commit 257573b

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

engine/cli/commands/server_start_cmd.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,16 @@ bool ServerStartCmd::Exec(const std::string& host, int port,
6565
si.cb = sizeof(si);
6666
ZeroMemory(&pi, sizeof(pi));
6767
std::wstring params = L"--start-server";
68-
params += L" --config_file_path " +
69-
file_manager_utils::GetConfigurationPath().wstring();
70-
params += L" --data_folder_path " +
71-
file_manager_utils::GetCortexDataPath().wstring();
68+
params += L" --config_file_path \"" +
69+
file_manager_utils::GetConfigurationPath().wstring() + L"\"";
70+
params += L" --data_folder_path \"" +
71+
file_manager_utils::GetCortexDataPath().wstring() + L"\"";
7272
params += L" --loglevel " + cortex::wc::Utf8ToWstring(log_level_);
7373
std::wstring exe_w = cortex::wc::Utf8ToWstring(exe);
7474
std::wstring current_path_w =
7575
file_manager_utils::GetExecutableFolderContainerPath().wstring();
76-
std::wstring wcmds = current_path_w + L"/" + exe_w + L" " + params;
77-
CTL_DBG("wcmds: " << wcmds);
76+
std::wstring wcmds = current_path_w + L"\\" + exe_w + L" " + params;
77+
CTL_INF("wcmds: " << wcmds);
7878
std::vector<wchar_t> mutable_cmds(wcmds.begin(), wcmds.end());
7979
mutable_cmds.push_back(L'\0');
8080
// Create child process

engine/extensions/remote-engine/remote_engine.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ size_t StreamWriteCallback(char* ptr, size_t size, size_t nmemb,
3131
Json::Reader reader;
3232
if (reader.parse(chunk, check_error)) {
3333
CTL_WRN(chunk);
34+
CTL_INF("Request: " << context->last_request);
3435
Json::Value status;
3536
status["is_done"] = true;
3637
status["has_error"] = true;
@@ -143,7 +144,9 @@ CurlResponse RemoteEngine::MakeStreamingChatCompletionRequest(
143144
"",
144145
config.model,
145146
renderer_,
146-
stream_template};
147+
stream_template,
148+
true,
149+
body};
147150

148151
curl_easy_setopt(curl, CURLOPT_URL, full_url.c_str());
149152
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);

engine/extensions/remote-engine/remote_engine.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ struct StreamContext {
2525
extensions::TemplateRenderer& renderer;
2626
std::string stream_template;
2727
bool need_stop = true;
28+
std::string last_request;
2829
};
2930
struct CurlResponse {
3031
std::string body;

engine/services/hardware_service.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,16 @@ bool HardwareService::Restart(const std::string& host, int port) {
143143
ZeroMemory(&pi, sizeof(pi));
144144
// TODO (sang) write a common function for this and server_start_cmd
145145
std::wstring params = L"--ignore_cout";
146-
params += L" --config_file_path " +
147-
file_manager_utils::GetConfigurationPath().wstring();
148-
params += L" --data_folder_path " +
149-
file_manager_utils::GetCortexDataPath().wstring();
146+
params += L" --config_file_path \"" +
147+
file_manager_utils::GetConfigurationPath().wstring() + L"\"";
148+
params += L" --data_folder_path \"" +
149+
file_manager_utils::GetCortexDataPath().wstring() + L"\"";
150150
params += L" --loglevel " +
151151
cortex::wc::Utf8ToWstring(luh::LogLevelStr(luh::global_log_level));
152152
std::wstring exe_w = exe.wstring();
153153
std::wstring current_path_w =
154154
file_manager_utils::GetExecutableFolderContainerPath().wstring();
155-
std::wstring wcmds = current_path_w + L"/" + exe_w + L" " + params;
155+
std::wstring wcmds = current_path_w + L"\\" + exe_w + L" " + params;
156156
CTL_DBG("wcmds: " << wcmds);
157157
std::vector<wchar_t> mutable_cmds(wcmds.begin(), wcmds.end());
158158
mutable_cmds.push_back(L'\0');

0 commit comments

Comments
 (0)