~aleteoryx/muditaos

2d0becaaf303f0429ce6c2c388029df82fada8f1 — Mateusz Grzegorzek 4 years ago d62dabb
[EGD-6571] Fix error message

`std::filesystem::remove_all` function returns
number of files and directions removed.
Return value in `cleanupAfterUpdate` from this function
wasn't properly interpreted and returns an error even if shouldn't.
1 files changed, 3 insertions(+), 4 deletions(-)

M module-services/service-desktop/endpoints/update/UpdateMuditaOS.cpp
M module-services/service-desktop/endpoints/update/UpdateMuditaOS.cpp => module-services/service-desktop/endpoints/update/UpdateMuditaOS.cpp +3 -4
@@ 535,10 535,9 @@ bool UpdateMuditaOS::unpackFileToTemp(mtar_header_t &h, unsigned long *crc32)
updateos::UpdateError UpdateMuditaOS::cleanupAfterUpdate()
{
    try {
        if (std::filesystem::is_directory(updateTempDirectory.c_str()) &&
            std::filesystem::remove_all(updateTempDirectory.c_str())) {
            return informError(
                updateos::UpdateError::CantRemoveUniqueTmpDir, "remove_all failed on %s", updateTempDirectory.c_str());
        if (std::filesystem::is_directory(updateTempDirectory.c_str())) {
            const auto numOfFilesRemoved = std::filesystem::remove_all(updateTempDirectory.c_str());
            LOG_DEBUG("Number of files and directories removed: %lu", static_cast<unsigned long>(numOfFilesRemoved));
        }
    }
    catch (const std::filesystem::filesystem_error &e) {