fix: Retry cleanup again on system exit
This commit is contained in:
parent
c57f0a1462
commit
d801e151ad
1 changed files with 9 additions and 1 deletions
|
@ -41,12 +41,20 @@ public class OpenSSLCertificateResult implements CertificateUsage {
|
|||
|
||||
@Override
|
||||
public void close() {
|
||||
cleanupDir(true);
|
||||
}
|
||||
|
||||
private void cleanupDir(boolean retryOnExit) {
|
||||
|
||||
try {
|
||||
log.info("Cleaning up temporary output directory {}", tmpDir);
|
||||
Files.walkFileTree(tmpDir, Set.of(), Integer.MAX_VALUE, new DeleteRecursiveFileVisitor());
|
||||
Files.deleteIfExists(tmpDir);
|
||||
} catch (IOException e) {
|
||||
log.error("Failed to clean up temporary output directory {}!", tmpDir, e);
|
||||
log.error("Failed to clean up temporary output directory {}! (retry={})", tmpDir, retryOnExit, e);
|
||||
if (retryOnExit) {
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> cleanupDir(false)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue