Skip to content

Commit 14f15a8

Browse files
committed
Fix invalid paths with missing trailing /
1 parent 979f089 commit 14f15a8

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

examples/server/main.cpp

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,9 +1345,10 @@ bool parseJsonPrompt(std::string json_str, SDParams* params) {
13451345
bool change = false;
13461346
int index = o.get<int>();
13471347
if (index >= 0 && index < model_part_files.size()) {
1348-
std::string new_path = model_part_dir + model_part_files[index];
1349-
if (model_part_path != new_path) {
1350-
model_part_path = new_path;
1348+
std::filesystem::path new_path = std::filesystem::path(model_part_dir) / model_part_files[index];
1349+
std::string new_path_str = new_path.string();
1350+
if (model_part_path != new_path_str) {
1351+
model_part_path = new_path_str;
13511352
change = true;
13521353
}
13531354
} else if (index == MODEL_UNLOAD) {
@@ -1397,9 +1398,10 @@ bool parseJsonPrompt(std::string json_str, SDParams* params) {
13971398
bool change = false;
13981399
int model_index = o.get<int>();
13991400
if (model_index >= 0 && model_index < params->models_files.size()) {
1400-
std::string new_path = params->models_dir + params->models_files[model_index];
1401-
if (params->ctxParams.model_path != new_path) {
1402-
params->ctxParams.model_path = new_path;
1401+
std::filesystem::path new_path = std::filesystem::path(params->models_dir) / params->models_files[model_index];
1402+
std::string new_path_str = new_path.string();
1403+
if (params->ctxParams.model_path != new_path_str) {
1404+
params->ctxParams.model_path = new_path_str;
14031405
params->ctxParams.diffusion_model_path = "";
14041406
change = true;
14051407
}
@@ -1419,9 +1421,10 @@ bool parseJsonPrompt(std::string json_str, SDParams* params) {
14191421
bool change = false;
14201422
int model_index = o.get<int>();
14211423
if (model_index >= 0 && model_index < params->diffusion_models_files.size()) {
1422-
std::string new_path = params->diffusion_models_dir + params->diffusion_models_files[model_index];
1423-
if (params->ctxParams.diffusion_model_path != new_path) {
1424-
params->ctxParams.diffusion_model_path = new_path;
1424+
std::filesystem::path new_path = std::filesystem::path(params->diffusion_models_dir) / params->diffusion_models_files[model_index];
1425+
std::string new_path_str = new_path.string();
1426+
if (params->ctxParams.diffusion_model_path != new_path_str) {
1427+
params->ctxParams.diffusion_model_path = new_path_str;
14251428
params->ctxParams.model_path = "";
14261429
change = true;
14271430
}
@@ -1441,9 +1444,10 @@ bool parseJsonPrompt(std::string json_str, SDParams* params) {
14411444
bool change = false;
14421445
int model_index = o.get<int>();
14431446
if (model_index >= 0 && model_index < params->diffusion_models_files.size()) {
1444-
std::string new_path = params->diffusion_models_dir + params->diffusion_models_files[model_index];
1445-
if (params->ctxParams.high_noise_diffusion_model_path != new_path) {
1446-
params->ctxParams.high_noise_diffusion_model_path = new_path;
1447+
std::filesystem::path new_path = std::filesystem::path(params->diffusion_models_dir) / params->diffusion_models_files[model_index];
1448+
std::string new_path_str = new_path.string();
1449+
if (params->ctxParams.high_noise_diffusion_model_path != new_path_str) {
1450+
params->ctxParams.high_noise_diffusion_model_path = new_path_str;
14471451
change = true;
14481452
}
14491453
} else {

0 commit comments

Comments
 (0)