mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-30 06:43:28 +01:00
core: do not download an update we already downloaded
This commit is contained in:
parent
45101550f2
commit
708758b737
@ -1100,7 +1100,7 @@ namespace cryptonote
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
std::string version, hash;
|
std::string version, hash;
|
||||||
MDEBUG("Checking for a new " << software << " version for " << buildtag);
|
MCDEBUG("updates", "Checking for a new " << software << " version for " << buildtag);
|
||||||
if (!tools::check_updates(software, buildtag, m_testnet, version, hash))
|
if (!tools::check_updates(software, buildtag, m_testnet, version, hash))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -1121,28 +1121,37 @@ namespace cryptonote
|
|||||||
filename = std::string(software) + "-update-" + version;
|
filename = std::string(software) + "-update-" + version;
|
||||||
boost::filesystem::path path(epee::string_tools::get_current_module_folder());
|
boost::filesystem::path path(epee::string_tools::get_current_module_folder());
|
||||||
path /= filename;
|
path /= filename;
|
||||||
|
|
||||||
|
crypto::hash file_hash;
|
||||||
|
if (!tools::sha256sum(path.string(), file_hash) || (hash != epee::string_tools::pod_to_hex(file_hash)))
|
||||||
|
{
|
||||||
|
MCDEBUG("updates", "We don't have that file already, downloading");
|
||||||
if (!tools::download(path.string(), url))
|
if (!tools::download(path.string(), url))
|
||||||
{
|
{
|
||||||
MERROR("Failed to download " << url);
|
MCERROR("updates", "Failed to download " << url);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
crypto::hash file_hash;
|
|
||||||
if (!tools::sha256sum(path.string(), file_hash))
|
if (!tools::sha256sum(path.string(), file_hash))
|
||||||
{
|
{
|
||||||
MERROR("Failed to hash " << path);
|
MCERROR("updates", "Failed to hash " << path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (hash != epee::string_tools::pod_to_hex(file_hash))
|
if (hash != epee::string_tools::pod_to_hex(file_hash))
|
||||||
{
|
{
|
||||||
MERROR("Download from " << url << " does not match the expected hash");
|
MCERROR("updates", "Download from " << url << " does not match the expected hash");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
MGINFO("New version downloaded to " << path);
|
MCINFO("updates", "New version downloaded to " << path);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MCDEBUG("updates", "We already have " << path << " with expected hash");
|
||||||
|
}
|
||||||
|
|
||||||
if (check_updates_level == UPDATES_DOWNLOAD)
|
if (check_updates_level == UPDATES_DOWNLOAD)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
MERROR("Download/update not implemented yet");
|
MCERROR("updates", "Download/update not implemented yet");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user