Skip to content

Commit

Permalink
Delete temp files immediately after use
Browse files Browse the repository at this point in the history
  • Loading branch information
NeRdTheNed committed Aug 9, 2023
1 parent 2ce7db6 commit e9c4a9e
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -733,8 +733,17 @@ public boolean optimiseJar(Path input, Path output, boolean overwrite) throws IO
returnVal = optimiseJar(archive, outputStream);
}

if (returnVal && handleSame) {
Files.copy(possibleTempPath, output, StandardCopyOption.REPLACE_EXISTING);
if (handleSame) {
if (returnVal) {
Files.copy(possibleTempPath, output, StandardCopyOption.REPLACE_EXISTING);
}

try {
Files.deleteIfExists(possibleTempPath);
} catch (final Exception e) {
System.err.println("Issue deleting temporary file " + possibleTempPath);
e.printStackTrace();
}
}

return returnVal;
Expand Down

0 comments on commit e9c4a9e

Please sign in to comment.