From 9b3b908d0ad6b8dfcd9804e1b45fe550593d5696 Mon Sep 17 00:00:00 2001 From: Szum123321 Date: Tue, 20 Dec 2022 00:46:46 +0100 Subject: [PATCH] removed redundant counter --- .../create/compressors/AbstractCompressor.java | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/main/java/net/szum123321/textile_backup/core/create/compressors/AbstractCompressor.java b/src/main/java/net/szum123321/textile_backup/core/create/compressors/AbstractCompressor.java index c50c1d3..559688d 100644 --- a/src/main/java/net/szum123321/textile_backup/core/create/compressors/AbstractCompressor.java +++ b/src/main/java/net/szum123321/textile_backup/core/create/compressors/AbstractCompressor.java @@ -37,7 +37,6 @@ import java.time.Instant; import java.util.Optional; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; -import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Stream; /** @@ -57,22 +56,15 @@ public abstract class AbstractCompressor { OutputStream arc = createArchiveOutputStream(bufferedOutputStream, ctx, coreLimit); Stream fileStream = Files.walk(inputFile)) { - AtomicInteger fileCounter = new AtomicInteger(0); //number of files to compress - - var it = fileStream + var fileList = fileStream .filter(path -> !Utilities.isBlacklisted(inputFile.relativize(path))) .filter(Files::isRegularFile) - .peek(x -> fileCounter.incrementAndGet()).toList() - .iterator(); - - log.info("File count: {}", fileCounter.get()); + .toList(); //will be used in conjunction with ParallelZip to avoid race condition - CountDownLatch latch = new CountDownLatch(fileCounter.get()); - - while(it.hasNext()) { - Path file = it.next(); + CountDownLatch latch = new CountDownLatch(fileList.size()); + for (Path file : fileList) { try { addEntry( new FileInputStreamSupplier(