From 96dc531c6eb0d0b600ffb2ef4a88650c5602c854 Mon Sep 17 00:00:00 2001 From: vansangpfiev Date: Mon, 21 Oct 2024 13:22:22 +0700 Subject: [PATCH 1/2] fix: print message if model is already downloaded --- engine/cli/commands/run_cmd.cc | 4 ++++ engine/services/model_service.cc | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/engine/cli/commands/run_cmd.cc b/engine/cli/commands/run_cmd.cc index 074c12709..49712165a 100644 --- a/engine/cli/commands/run_cmd.cc +++ b/engine/cli/commands/run_cmd.cc @@ -35,6 +35,10 @@ void RunCmd::Exec(bool run_detach) { auto related_models_ids = modellist_handler.FindRelatedModel(model_handle_); if (related_models_ids.has_error() || related_models_ids.value().empty()) { auto result = model_service_.DownloadModel(model_handle_); + if(result.has_error()) { + CLI_LOG(result.error()); + return; + } model_id = result.value(); CTL_INF("model_id: " << model_id.value()); } else if (related_models_ids.value().size() == 1) { diff --git a/engine/services/model_service.cc b/engine/services/model_service.cc index 3db54d997..58051ebc5 100644 --- a/engine/services/model_service.cc +++ b/engine/services/model_service.cc @@ -316,7 +316,7 @@ cpp::result ModelService::HandleUrl( if (model_entry.has_value()) { CLI_LOG("Model already downloaded: " << unique_model_id); - return cpp::fail("Please delete the model before downloading again"); + return unique_model_id; } auto local_path{file_manager_utils::GetModelsContainerPath() / From f94c74b469ab97e861960455463b60051ce819bb Mon Sep 17 00:00:00 2001 From: vansangpfiev Date: Mon, 21 Oct 2024 13:45:21 +0700 Subject: [PATCH 2/2] fix: format --- engine/cli/commands/run_cmd.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/cli/commands/run_cmd.cc b/engine/cli/commands/run_cmd.cc index 49712165a..50b38d4c6 100644 --- a/engine/cli/commands/run_cmd.cc +++ b/engine/cli/commands/run_cmd.cc @@ -35,7 +35,7 @@ void RunCmd::Exec(bool run_detach) { auto related_models_ids = modellist_handler.FindRelatedModel(model_handle_); if (related_models_ids.has_error() || related_models_ids.value().empty()) { auto result = model_service_.DownloadModel(model_handle_); - if(result.has_error()) { + if (result.has_error()) { CLI_LOG(result.error()); return; }