removed redundant counter

This commit is contained in:
Szum123321 2022-12-20 00:46:46 +01:00
parent 663089a7a3
commit 9b3b908d0a

View File

@ -37,7 +37,6 @@ import java.time.Instant;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Stream; import java.util.stream.Stream;
/** /**
@ -57,22 +56,15 @@ public abstract class AbstractCompressor {
OutputStream arc = createArchiveOutputStream(bufferedOutputStream, ctx, coreLimit); OutputStream arc = createArchiveOutputStream(bufferedOutputStream, ctx, coreLimit);
Stream<Path> fileStream = Files.walk(inputFile)) { Stream<Path> fileStream = Files.walk(inputFile)) {
AtomicInteger fileCounter = new AtomicInteger(0); //number of files to compress var fileList = fileStream
var it = fileStream
.filter(path -> !Utilities.isBlacklisted(inputFile.relativize(path))) .filter(path -> !Utilities.isBlacklisted(inputFile.relativize(path)))
.filter(Files::isRegularFile) .filter(Files::isRegularFile)
.peek(x -> fileCounter.incrementAndGet()).toList() .toList();
.iterator();
log.info("File count: {}", fileCounter.get());
//will be used in conjunction with ParallelZip to avoid race condition //will be used in conjunction with ParallelZip to avoid race condition
CountDownLatch latch = new CountDownLatch(fileCounter.get()); CountDownLatch latch = new CountDownLatch(fileList.size());
while(it.hasNext()) {
Path file = it.next();
for (Path file : fileList) {
try { try {
addEntry( addEntry(
new FileInputStreamSupplier( new FileInputStreamSupplier(