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

Commit 61b44a8

Browse files
authored
Merge pull request #1836 from janhq/chore/v1.0.7-rc1
Cherry-pick dev to main v1.0.7-rc1
2 parents f56bf9b + 9ba4886 commit 61b44a8

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

engine/services/engine_service.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ cpp::result<bool, std::string> EngineService::UnzipEngine(
132132
CTL_INF("Found cuda variant, extract it");
133133
found_cuda = true;
134134
// extract binary
135-
auto cuda_path =
136-
file_manager_utils::GetCudaToolkitPath(NormalizeEngine(engine));
135+
auto cuda_path = file_manager_utils::GetCudaToolkitPath(
136+
NormalizeEngine(engine), true);
137137
archive_utils::ExtractArchive(path + "/" + cf, cuda_path.string(),
138138
true);
139139
}
@@ -434,7 +434,8 @@ cpp::result<bool, std::string> EngineService::DownloadCuda(
434434
}};
435435

436436
auto on_finished = [engine](const DownloadTask& finishedTask) {
437-
auto engine_path = file_manager_utils::GetCudaToolkitPath(engine);
437+
auto engine_path = file_manager_utils::GetCudaToolkitPath(engine, true);
438+
438439
archive_utils::ExtractArchive(finishedTask.items[0].localPath.string(),
439440
engine_path.string());
440441
try {

engine/utils/file_manager_utils.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,13 +289,14 @@ std::filesystem::path GetModelsContainerPath() {
289289
return models_container_path;
290290
}
291291

292-
std::filesystem::path GetCudaToolkitPath(const std::string& engine) {
292+
std::filesystem::path GetCudaToolkitPath(const std::string& engine,
293+
bool create_if_not_exist) {
293294
auto engine_path = getenv("ENGINE_PATH")
294295
? std::filesystem::path(getenv("ENGINE_PATH"))
295296
: GetCortexDataPath();
296297

297298
auto cuda_path = engine_path / "engines" / engine / "deps";
298-
if (!std::filesystem::exists(cuda_path)) {
299+
if (create_if_not_exist && !std::filesystem::exists(cuda_path)) {
299300
std::filesystem::create_directories(cuda_path);
300301
}
301302

engine/utils/file_manager_utils.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ void CreateDirectoryRecursively(const std::string& path);
4545

4646
std::filesystem::path GetModelsContainerPath();
4747

48-
std::filesystem::path GetCudaToolkitPath(const std::string& engine);
48+
std::filesystem::path GetCudaToolkitPath(const std::string& engine,
49+
bool create_if_not_exist = false);
4950

5051
std::filesystem::path GetEnginesContainerPath();
5152

0 commit comments

Comments
 (0)