mirror of https://github.com/mamba-org/mamba.git
fix: Remove invalid cached tarballs (#3839)
Signed-off-by: Julien Jerphanion <git@jjerphan.xyz> Co-authored-by: Klaim <Klaim@users.noreply.github.com>
This commit is contained in:
parent
04b2f2cae3
commit
e5004266cb
|
@ -5,6 +5,7 @@
|
|||
// The full license is in the file LICENSE, distributed with this software.
|
||||
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
|
@ -168,7 +169,38 @@ namespace mamba
|
|||
}
|
||||
else
|
||||
{
|
||||
LOG_WARNING << "Package tarball '" << tarball_path.string() << "' is invalid";
|
||||
std::stringstream msg;
|
||||
msg << "Package tarball '" << tarball_path.string() << "' is invalid.\n";
|
||||
if (s.size != 0)
|
||||
{
|
||||
msg << " - Expected size : " << s.size << "\n"
|
||||
<< " - Effective size : " << fs::file_size(tarball_path) << "\n";
|
||||
}
|
||||
if (!s.md5.empty())
|
||||
{
|
||||
msg << " - Expected md5 : " << s.md5 << "\n"
|
||||
<< " - Effective md5 : " << validation::md5sum(tarball_path) << "\n";
|
||||
}
|
||||
if (!s.sha256.empty())
|
||||
{
|
||||
msg << " - Expected sha256 : " << s.sha256 << "\n"
|
||||
<< " - Effective sha256 : " << validation::sha256sum(tarball_path) << "\n";
|
||||
}
|
||||
msg << "Deleting '" << tarball_path.string() << "'";
|
||||
LOG_TRACE << msg.str();
|
||||
|
||||
std::error_code ec;
|
||||
fs::remove(tarball_path, ec);
|
||||
|
||||
if (ec)
|
||||
{
|
||||
LOG_ERROR << "Failed to remove invalid tarball '" << tarball_path.string()
|
||||
<< "' (error_code: " << ec.message() << ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_TRACE << "Package tarball '" << tarball_path.string() << "' removed";
|
||||
}
|
||||
}
|
||||
m_valid_tarballs[pkg] = valid;
|
||||
}
|
||||
|
|
|
@ -162,7 +162,11 @@ namespace mamba
|
|||
{
|
||||
LOG_ERROR << "Failed to download package from "
|
||||
<< error.transfer.value().effective_url << " (status "
|
||||
<< error.transfer.value().http_status << ")";
|
||||
<< error.transfer.value().http_status << ")\n"
|
||||
<< "If you see this message repeatedly, the state of your installation might be corrupted,\n"
|
||||
<< "in which case running `mamba clean --all` might fix it.\n\n"
|
||||
<< "If you continue to meet this problem, please search or report an issue\n"
|
||||
<< "on mamba's issue tracker: https://github.com/mamba-org/mamba/issues/";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue