Skip to content

Commit

Permalink
Merge branch 'release' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Doxoh committed Feb 17, 2024
2 parents 02f155f + 133161b commit 3259320
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 16 deletions.
13 changes: 13 additions & 0 deletions client/src/coreclr/CoreClrValidation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,19 @@ void CoreClr::DownloadRuntime(alt::IHttpClient* httpClient, Progress& progress)
return;
} catch (std::runtime_error& e) {
cs::Log::Error << "Failed to extract zip: " << e.what() << cs::Log::Endl;

auto path = GetDataDirectoryPath() / "runtime.zip";
try
{
cs::Log::Info << "Writing debug ZIP to: " << path.string() << cs::Log::Endl;
std::ofstream os(path);
os << response.body;
os.close();
cs::Log::Info << "Writing debug ZIP finished" << cs::Log::Endl;
} catch(std::runtime_error& e)
{
cs::Log::Info << "Writing debug ZIP failed: " << e.what() << cs::Log::Endl;
}
}
}
}
Expand Down
41 changes: 26 additions & 15 deletions client/src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <string>
#include <codecvt>
#include <future>
#include <Log.h>

EXTERN_C IMAGE_DOS_HEADER __ImageBase;

Expand Down Expand Up @@ -100,24 +101,34 @@ namespace utils
}

inline alt::IHttpClient::HttpResponse download_file_sync(alt::IHttpClient* httpClient, const std::string& url) {
std::promise<alt::IHttpClient::HttpResponse> promise;
std::future<alt::IHttpClient::HttpResponse> future = promise.get_future();
auto attempt = 0;

while (true)
{
if (++attempt > 5) throw std::runtime_error("Failed to download file " + url);

std::promise<alt::IHttpClient::HttpResponse> promise;
std::future<alt::IHttpClient::HttpResponse> future = promise.get_future();

httpClient->Get([](alt::IHttpClient::HttpResponse response, const void* data) {
const auto innerPromise = (std::promise<alt::IHttpClient::HttpResponse>*) data;
httpClient->Get([](alt::IHttpClient::HttpResponse response, const void* data) {
const auto innerPromise = (std::promise<alt::IHttpClient::HttpResponse>*) data;

if (response.statusCode != 200) {
innerPromise->set_exception(std::make_exception_ptr(std::runtime_error("Failed to download file")));
return;
}
if (response.statusCode != 200) {
std::stringstream ss;
ss << "HTTP " << response.statusCode << " " << response.body;
innerPromise->set_exception(std::make_exception_ptr(std::runtime_error(ss.str())));
return;
}

innerPromise->set_value(response);
}, url, &promise);

try {
return future.get();
} catch(const std::exception&) {
throw std::runtime_error("Failed to download file " + url);
innerPromise->set_value(response);
}, url, &promise);

try {
return future.get();
} catch(const std::exception& e) {
cs::Log::Warning << "Failed to download file " << url << ", attempt " << attempt << ": " << e.what() << cs::Log::Endl;
std::this_thread::sleep_for(std::chrono::seconds(1));
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion cpp-sdk
Submodule cpp-sdk updated 1 files
+20 −0 types/Metric.h
5 changes: 5 additions & 0 deletions server/src/CSharpResourceImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,12 @@ case alt::CEvent::Type::SYNCED_META_CHANGE:
auto name = scriptRPCEvent->GetName();
auto args = scriptRPCEvent->GetArgs();
auto size = args.size();

#ifdef _WIN32
auto constArgs = new alt::MValueConst*[size];
#else
alt::MValueConst* constArgs[size];
#endif

for (uint64_t i = 0; i < size; i++)
{
Expand Down

0 comments on commit 3259320

Please sign in to comment.