Skip to content

Commit 5653404

Browse files
committed
Delete temp directory at the end of the operations
I would have squashed it but it's not easy to squash into initial commit due to conflicts.
1 parent 634d58a commit 5653404

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

core/deployment/src/main/java/io/quarkus/deployment/pkg/jar/ParallelCommonsCompressArchiveCreator.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public class ParallelCommonsCompressArchiveCreator implements ArchiveCreator {
5252
private final ParallelScatterZipCreator scatterZipCreator;
5353
private final ScatterZipOutputStream directories;
5454
private final int compressionMethod;
55+
private final Path tempDirectory;
5556

5657
private final Map<String, String> addedFiles = new HashMap<>();
5758

@@ -69,11 +70,12 @@ public class ParallelCommonsCompressArchiveCreator implements ArchiveCreator {
6970
this.archivePath = archivePath;
7071
this.archive = new ZipArchiveOutputStream(archivePath);
7172
this.archive.setMethod(compressionMethod);
73+
this.tempDirectory = Files.createTempDirectory(outputTarget, "zip-builder-files");
7274

7375
scatterZipCreator = new ParallelScatterZipCreator(
7476
// we need to make sure our own executor won't be shut down by Commons Compress...
7577
new DoNotShutdownDelegatingExecutorService(executorService),
76-
new DefaultBackingStoreSupplier(Files.createTempDirectory(outputTarget, "zip-builder-files")),
78+
new DefaultBackingStoreSupplier(this.tempDirectory),
7779
compressionLevel);
7880
directories = ScatterZipOutputStream.pathBased(Files.createTempFile(outputTarget, "zip-builder-dirs", ""),
7981
compressionLevel);
@@ -224,6 +226,11 @@ public void close() {
224226
} catch (IOException | InterruptedException | ExecutionException e) {
225227
throw new IllegalStateException("Unable to create archive: " + archivePath, e);
226228
}
229+
try {
230+
Files.deleteIfExists(tempDirectory);
231+
} catch (Exception e) {
232+
// noop, it's not a big deal to keep this directory around
233+
}
227234
}
228235

229236
private static class DoNotShutdownDelegatingExecutorService implements ExecutorService {

0 commit comments

Comments
 (0)