diff --git a/engine/services/engine_service.cc b/engine/services/engine_service.cc index 2ca06cb33..93311f98b 100644 --- a/engine/services/engine_service.cc +++ b/engine/services/engine_service.cc @@ -132,8 +132,8 @@ cpp::result EngineService::UnzipEngine( CTL_INF("Found cuda variant, extract it"); found_cuda = true; // extract binary - auto cuda_path = - file_manager_utils::GetCudaToolkitPath(NormalizeEngine(engine)); + auto cuda_path = file_manager_utils::GetCudaToolkitPath( + NormalizeEngine(engine), true); archive_utils::ExtractArchive(path + "/" + cf, cuda_path.string(), true); } @@ -434,7 +434,8 @@ cpp::result EngineService::DownloadCuda( }}; auto on_finished = [engine](const DownloadTask& finishedTask) { - auto engine_path = file_manager_utils::GetCudaToolkitPath(engine); + auto engine_path = file_manager_utils::GetCudaToolkitPath(engine, true); + archive_utils::ExtractArchive(finishedTask.items[0].localPath.string(), engine_path.string()); try { diff --git a/engine/utils/file_manager_utils.cc b/engine/utils/file_manager_utils.cc index 338abadac..aee65020c 100644 --- a/engine/utils/file_manager_utils.cc +++ b/engine/utils/file_manager_utils.cc @@ -289,13 +289,14 @@ std::filesystem::path GetModelsContainerPath() { return models_container_path; } -std::filesystem::path GetCudaToolkitPath(const std::string& engine) { +std::filesystem::path GetCudaToolkitPath(const std::string& engine, + bool create_if_not_exist) { auto engine_path = getenv("ENGINE_PATH") ? std::filesystem::path(getenv("ENGINE_PATH")) : GetCortexDataPath(); auto cuda_path = engine_path / "engines" / engine / "deps"; - if (!std::filesystem::exists(cuda_path)) { + if (create_if_not_exist && !std::filesystem::exists(cuda_path)) { std::filesystem::create_directories(cuda_path); } diff --git a/engine/utils/file_manager_utils.h b/engine/utils/file_manager_utils.h index 91102d002..059fe6ae3 100644 --- a/engine/utils/file_manager_utils.h +++ b/engine/utils/file_manager_utils.h @@ -45,7 +45,8 @@ void CreateDirectoryRecursively(const std::string& path); std::filesystem::path GetModelsContainerPath(); -std::filesystem::path GetCudaToolkitPath(const std::string& engine); +std::filesystem::path GetCudaToolkitPath(const std::string& engine, + bool create_if_not_exist = false); std::filesystem::path GetEnginesContainerPath();