mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-06-06 18:30:57 +00:00
# Description of Changes Please provide a summary of the changes, including: - **What was changed**: - Modified the `ProcessExecutor` class to accept exit code `3` from **qpdf** as a success with warnings. - Added a check to ensure that only **qpdf**’s exit code `3` is treated as a warning. - Added a warning log for **qpdf** exit code `3` to provide better visibility into the repair process. - **Why the change was made**: - The repair process was failing when **qpdf** returned exit code `3`, even though the operation succeeded with warnings. This caused unnecessary errors for users. - The changes ensure that PDFs with minor structural issues (e.g., mismatched object counts) are still repaired successfully, while logging warnings for transparency. - Added a check to ensure that only **qpdf**’s exit code `3` is treated as a warning, preventing potential issues with other tools that might use exit code `3` for actual errors. Closes #2842 --- ## Checklist ### General - [x] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [x] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md) (if applicable) - [x] I have performed a self-review of my own code - [x] My changes generate no new warnings ### Testing (if applicable) - [x] I have tested my changes locally. - Verified that exit code `3` is only treated as a warning for **qpdf** and not for other tools. --- ### Additional Notes - The changes align with **qpdf**'s behavior, where exit code `3` indicates a successful operation with warnings. - Added a check to ensure that only **qpdf**’s exit code `3` is treated as a warning, preventing potential issues with other tools. Co-authored-by: Anthony Stirling <77850077+Frooodle@users.noreply.github.com>
This commit is contained in:
parent
5bf050d77f
commit
507d21772d
@ -218,6 +218,9 @@ public class ProcessExecutor {
|
||||
errorReaderThread.join();
|
||||
outputReaderThread.join();
|
||||
|
||||
boolean isQpdf =
|
||||
command != null && !command.isEmpty() && command.get(0).contains("qpdf");
|
||||
|
||||
if (outputLines.size() > 0) {
|
||||
String outputMessage = String.join("\n", outputLines);
|
||||
messages += outputMessage;
|
||||
@ -233,6 +236,9 @@ public class ProcessExecutor {
|
||||
log.warn("Command error output:\n" + errorMessage);
|
||||
}
|
||||
if (exitCode != 0) {
|
||||
if (isQpdf && exitCode == 3) {
|
||||
log.warn("qpdf succeeded with warnings: {}", messages);
|
||||
} else {
|
||||
throw new IOException(
|
||||
"Command process failed with exit code "
|
||||
+ exitCode
|
||||
@ -240,14 +246,19 @@ public class ProcessExecutor {
|
||||
+ errorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (exitCode != 0) {
|
||||
if (isQpdf && exitCode == 3) {
|
||||
log.warn("qpdf succeeded with warnings: {}", messages);
|
||||
} else {
|
||||
throw new IOException(
|
||||
"Command process failed with exit code "
|
||||
+ exitCode
|
||||
+ "\nLogs: "
|
||||
+ messages);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
semaphore.release();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user