winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 5c4c0b44157322b4c305af9b6c6a17ed77a2213e
parent 8a8ad84c47705971b62492808800045c6f91961f
Author: Kaleb Luedtke <trenlymc@gmail.com>
Date:   Fri, 30 Sep 2022 16:30:46 -0500

Additional logging when validating portable file fails (#2562)


Diffstat:
Msrc/AppInstallerCLICore/PortableInstaller.cpp | 13++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/AppInstallerCLICore/PortableInstaller.cpp b/src/AppInstallerCLICore/PortableInstaller.cpp @@ -60,15 +60,22 @@ namespace AppInstaller::CLI::Portable if (fileType == PortableFileType::File) { - if (std::filesystem::exists(filePath) && !SHA256::AreEqual(SHA256::ComputeHashFromFile(filePath), SHA256::ConvertToBytes(entry.SHA256))) + + if (std::filesystem::exists(filePath)) { - return false; + SHA256::HashBuffer fileHash = SHA256::ComputeHashFromFile(filePath); + if (!SHA256::AreEqual(fileHash, SHA256::ConvertToBytes(entry.SHA256))) + { + AICLI_LOG(CLI, Warning, << "File hash does not match ARP Entry. Expected: " << entry.SHA256 << " Actual: " << SHA256::ConvertToString(fileHash)); + return false; + } } } else if (fileType == PortableFileType::Symlink) { if (Filesystem::SymlinkExists(filePath) && !Filesystem::VerifySymlink(filePath, entry.SymlinkTarget)) { + AICLI_LOG(CLI, Warning, << "Symlink target does not match ARP Entry. Expected: " << entry.SymlinkTarget << " Actual: " << std::filesystem::read_symlink(filePath)); return false; } } @@ -121,7 +128,7 @@ namespace AppInstaller::CLI::Portable if (std::filesystem::remove(filePath)) { AICLI_LOG(CLI, Info, << "Removed existing file at " << filePath); - m_stream << Resource::String::OverwritingExistingFileAtMessage << ' ' << filePath << std::endl; + m_stream << Resource::String::OverwritingExistingFileAtMessage << ' ' << filePath.u8string() << std::endl; } if (Filesystem::CreateSymlink(entry.SymlinkTarget, filePath))