From 67df45152b9d89743e90fec86e655caf3c39a401 Mon Sep 17 00:00:00 2001 From: dengzhongyuan Date: Tue, 28 Apr 2026 11:30:55 +0800 Subject: [PATCH] fix: Prevent overwriting error states on successful exit codes in CliInterface - Updated the processFinished and extractProcessFinished methods to retain error states detected from stdout, even when the exit code is 0. - This change ensures that errors such as long file name issues are not masked by a successful exit code, improving error handling and user feedback. Enhances reliability in archive processing by maintaining accurate error reporting. bug: https://pms.uniontech.com/bug-view-338535.html --- 3rdparty/interface/archiveinterface/cliinterface.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/3rdparty/interface/archiveinterface/cliinterface.cpp b/3rdparty/interface/archiveinterface/cliinterface.cpp index 3e56a528..9ca201e8 100644 --- a/3rdparty/interface/archiveinterface/cliinterface.cpp +++ b/3rdparty/interface/archiveinterface/cliinterface.cpp @@ -1387,7 +1387,10 @@ void CliInterface::processFinished(int exitCode, QProcess::ExitStatus exitStatus m_isCorruptArchive = false; } - if (exitCode == 0) { // job正常结束 + // If we already detected an error from stdout parsing, do not overwrite it + // just because the cli tool exits with code 0 (e.g. unrar may return 0 even + // when some entries fail to extract, such as long file name cases). + if (exitCode == 0 && m_finishType != PFT_Error && m_finishType != PFT_Cancel) { m_finishType = PFT_Nomral; } @@ -1403,7 +1406,8 @@ void CliInterface::extractProcessFinished(int exitCode, QProcess::ExitStatus exi deleteProcess(); - if (0 == exitCode) { // job正常结束 + // Keep stdout-detected errors (e.g. long name) even if exitCode is 0. + if (0 == exitCode && m_finishType != PFT_Error && m_finishType != PFT_Cancel) { m_finishType = PFT_Nomral; }