mirror of
https://github.com/monero-project/monero.git
synced 2025-08-11 15:10:16 -04:00
core: updates can now be downloaded (and SHA256 hash checked)
This commit is contained in:
parent
216f062eb8
commit
a5a0a3c894
4 changed files with 206 additions and 0 deletions
|
@ -36,6 +36,7 @@ using namespace epee;
|
|||
#include "common/command_line.h"
|
||||
#include "common/util.h"
|
||||
#include "common/updates.h"
|
||||
#include "common/download.h"
|
||||
#include "warnings.h"
|
||||
#include "crypto/crypto.h"
|
||||
#include "cryptonote_config.h"
|
||||
|
@ -1090,6 +1091,35 @@ namespace cryptonote
|
|||
if (check_updates_level == UPDATES_NOTIFY)
|
||||
return true;
|
||||
|
||||
std::string filename;
|
||||
const char *slash = strrchr(url.c_str(), '/');
|
||||
if (slash)
|
||||
filename = slash + 1;
|
||||
else
|
||||
filename = std::string(software) + "-update-" + version;
|
||||
boost::filesystem::path path(epee::string_tools::get_current_module_folder());
|
||||
path /= filename;
|
||||
if (!tools::download(path.string(), url))
|
||||
{
|
||||
MERROR("Failed to download " << url);
|
||||
return false;
|
||||
}
|
||||
crypto::hash file_hash;
|
||||
if (!tools::sha256sum(path.string(), file_hash))
|
||||
{
|
||||
MERROR("Failed to hash " << path);
|
||||
return false;
|
||||
}
|
||||
if (hash != epee::string_tools::pod_to_hex(file_hash))
|
||||
{
|
||||
MERROR("Download from " << url << " does not match the expected hash");
|
||||
return false;
|
||||
}
|
||||
MGINFO("New version downloaded to " << path);
|
||||
|
||||
if (check_updates_level == UPDATES_DOWNLOAD)
|
||||
return true;
|
||||
|
||||
MERROR("Download/update not implemented yet");
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue