mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
Merge pull request #6463 from delroth/auto-update
Initial implementation of the Dolphin auto-updater for Windows
This commit is contained in:
@ -7,6 +7,7 @@
|
||||
#include <chrono>
|
||||
#include <cstddef>
|
||||
#include <curl/curl.h>
|
||||
#include <mutex>
|
||||
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Common/ScopeGuard.h"
|
||||
@ -30,9 +31,14 @@ public:
|
||||
size_t size);
|
||||
|
||||
private:
|
||||
std::unique_ptr<CURL, decltype(&curl_easy_cleanup)> m_curl{curl_easy_init(), curl_easy_cleanup};
|
||||
static std::mutex s_curl_was_inited_mutex;
|
||||
static bool s_curl_was_inited;
|
||||
std::unique_ptr<CURL, decltype(&curl_easy_cleanup)> m_curl{nullptr, curl_easy_cleanup};
|
||||
};
|
||||
|
||||
std::mutex HttpRequest::Impl::s_curl_was_inited_mutex;
|
||||
bool HttpRequest::Impl::s_curl_was_inited = false;
|
||||
|
||||
HttpRequest::HttpRequest(std::chrono::milliseconds timeout_ms)
|
||||
: m_impl(std::make_unique<Impl>(timeout_ms))
|
||||
{
|
||||
@ -65,6 +71,16 @@ HttpRequest::Response HttpRequest::Post(const std::string& url, const std::strin
|
||||
|
||||
HttpRequest::Impl::Impl(std::chrono::milliseconds timeout_ms)
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(s_curl_was_inited_mutex);
|
||||
if (!s_curl_was_inited)
|
||||
{
|
||||
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||
s_curl_was_inited = true;
|
||||
}
|
||||
}
|
||||
|
||||
m_curl.reset(curl_easy_init());
|
||||
if (!m_curl)
|
||||
return;
|
||||
|
||||
|
@ -81,6 +81,8 @@ var isStable = +("master" == branch || "stable" == branch);
|
||||
// Get environment information.
|
||||
var distributor = wshShell.ExpandEnvironmentStrings("%DOLPHIN_DISTRIBUTOR%");
|
||||
if (distributor == "%DOLPHIN_DISTRIBUTOR%") distributor = "None";
|
||||
var default_update_track = wshShell.ExpandEnvironmentStrings("%DOLPHIN_DEFAULT_UPDATE_TRACK%");
|
||||
if (default_update_track == "%DOLPHIN_DEFAULT_UPDATE_TRACK%") default_update_track = "";
|
||||
|
||||
// remove hash (and trailing "-0" if needed) from description
|
||||
describe = describe.replace(/(-0)?-[^-]+(-dirty)?$/, '$2');
|
||||
@ -90,7 +92,8 @@ var out_contents =
|
||||
"#define SCM_DESC_STR \"" + describe + "\"\n" +
|
||||
"#define SCM_BRANCH_STR \"" + branch + "\"\n" +
|
||||
"#define SCM_IS_MASTER " + isStable + "\n" +
|
||||
"#define SCM_DISTRIBUTOR_STR \"" + distributor + "\"\n";
|
||||
"#define SCM_DISTRIBUTOR_STR \"" + distributor + "\"\n" +
|
||||
"#define SCM_UPDATE_TRACK_STR \"" + default_update_track + "\"\n";
|
||||
|
||||
// check if file needs updating
|
||||
if (out_contents == GetFileContents(outfile))
|
||||
|
Reference in New Issue
Block a user