@@ -27,6 +27,16 @@ std::chrono::seconds GetTimeSinceEpochMillisec() {
2727 using namespace std ::chrono;
2828 return duration_cast<seconds>(system_clock::now ().time_since_epoch ());
2929}
30+
31+ std::unique_ptr<system_info_utils::SystemInfo> GetSystemInfoWithUniversal () {
32+ auto system_info = system_info_utils::GetSystemInfo ();
33+ if (system_info->os == " mac" ) {
34+ CTL_INF (" Change arch from " << system_info->arch << " to universal" );
35+ system_info->arch = " universal" ;
36+ }
37+ return system_info;
38+ }
39+
3040} // namespace
3141
3242std::optional<std::string> CheckNewUpdate (
@@ -222,7 +232,7 @@ void CortexUpdCmd::Exec(const std::string& v) {
222232}
223233
224234bool CortexUpdCmd::GetStable (const std::string& v) {
225- auto system_info = system_info_utils::GetSystemInfo ();
235+ auto system_info = GetSystemInfoWithUniversal ();
226236 CTL_INF (" OS: " << system_info->os << " , Arch: " << system_info->arch );
227237
228238 // Download file
@@ -276,7 +286,7 @@ bool CortexUpdCmd::GetStable(const std::string& v) {
276286}
277287
278288bool CortexUpdCmd::GetBeta (const std::string& v) {
279- auto system_info = system_info_utils::GetSystemInfo ();
289+ auto system_info = GetSystemInfoWithUniversal ();
280290 CTL_INF (" OS: " << system_info->os << " , Arch: " << system_info->arch );
281291
282292 // Download file
@@ -407,11 +417,11 @@ bool CortexUpdCmd::HandleGithubRelease(const nlohmann::json& assets,
407417}
408418
409419bool CortexUpdCmd::GetNightly (const std::string& v) {
410- auto system_info = system_info_utils::GetSystemInfo ();
420+ auto system_info = GetSystemInfoWithUniversal ();
411421 CTL_INF (" OS: " << system_info->os << " , Arch: " << system_info->arch );
412422
413423 // Download file
414- std::string version = v.empty () ? " latest" : std::move (v) ;
424+ std::string version = v.empty () ? " latest" : v ;
415425 std::string os_arch{system_info->os + " -" + system_info->arch };
416426 const char * paths[] = {
417427 " cortex" ,
@@ -447,7 +457,7 @@ bool CortexUpdCmd::GetNightly(const std::string& v) {
447457 .localPath = localPath,
448458 }}};
449459
450- DownloadService ().AddDownloadTask (
460+ auto res = DownloadService ().AddDownloadTask (
451461 download_task, [](const DownloadTask& finishedTask) {
452462 // try to unzip the downloaded file
453463 CTL_INF (" Downloaded engine path: "
@@ -462,6 +472,11 @@ bool CortexUpdCmd::GetNightly(const std::string& v) {
462472 CTL_INF (" Finished!" );
463473 });
464474
475+ if (res.has_error ()) {
476+ CLI_LOG (" Download failed!" );
477+ return false ;
478+ }
479+
465480 // Replace binary file
466481 auto executable_path = file_manager_utils::GetExecutableFolderContainerPath ();
467482 auto src =
0 commit comments