diff --git a/libmamba/src/core/package_cache.cpp b/libmamba/src/core/package_cache.cpp index f40918604..caa7fd04c 100644 --- a/libmamba/src/core/package_cache.cpp +++ b/libmamba/src/core/package_cache.cpp @@ -5,6 +5,7 @@ // The full license is in the file LICENSE, distributed with this software. #include +#include #include @@ -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; } diff --git a/libmamba/src/core/package_fetcher.cpp b/libmamba/src/core/package_fetcher.cpp index 154c96601..f2cd5dfdc 100644 --- a/libmamba/src/core/package_fetcher.cpp +++ b/libmamba/src/core/package_fetcher.cpp @@ -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 {