Skip to content

Commit

Permalink
fix: not create new folder if is registering paths (#1828)
Browse files Browse the repository at this point in the history
  • Loading branch information
namchuai authored Dec 27, 2024
1 parent 1a73c0c commit 3456c7b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
7 changes: 4 additions & 3 deletions engine/services/engine_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ cpp::result<bool, std::string> 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);
}
Expand Down Expand Up @@ -434,7 +434,8 @@ cpp::result<bool, std::string> 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 {
Expand Down
5 changes: 3 additions & 2 deletions engine/utils/file_manager_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
3 changes: 2 additions & 1 deletion engine/utils/file_manager_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 3456c7b

Please sign in to comment.