🚧 Fix issue where cert cleanup fails
- Delete temp directory using FileTree visitor recursively - Update CertificateRequestBuilder to accept subject info directly from builder
This commit is contained in:
parent
98a6556bf9
commit
b5571aa2e5
6 changed files with 124 additions and 87 deletions
|
|
@ -0,0 +1,47 @@
|
|||
package de.mlessmann.certassist;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.springframework.lang.NonNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.FileVisitResult;
|
||||
import java.nio.file.FileVisitor;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
|
||||
import static org.slf4j.LoggerFactory.getLogger;
|
||||
|
||||
public class DeleteRecursiveFileVisitor implements FileVisitor<Path> {
|
||||
|
||||
private static final Logger LOGGER = getLogger(DeleteRecursiveFileVisitor.class);
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public FileVisitResult preVisitDirectory(Path dir, @NonNull BasicFileAttributes attrs) throws IOException {
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, @NonNull BasicFileAttributes attrs) throws IOException {
|
||||
LOGGER.trace("Deleting file {}", file);
|
||||
Files.delete(file);
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public FileVisitResult visitFileFailed(Path file, @NonNull IOException exc) throws IOException {
|
||||
LOGGER.error("Could not delete file {}", file, exc);
|
||||
throw exc;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
|
||||
LOGGER.trace("Deleting directory {}", dir);
|
||||
Files.delete(dir);
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue