From b82858725299dea89b78d0a29ca88b15ac5a6f4f Mon Sep 17 00:00:00 2001 From: "miriam.baglioni" Date: Fri, 30 Oct 2020 15:01:25 +0100 Subject: [PATCH] prevent the code to cicle indefinetly --- .../main/java/eu/dnetlib/dhp/oa/graph/dump/MakeTar.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/MakeTar.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/MakeTar.java index 89c65fb33b..634d43cf8e 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/MakeTar.java +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/MakeTar.java @@ -88,16 +88,16 @@ public class MakeTar implements Serializable { write(fileSystem, inputPath, outputPath + ".tar", dir_name); } else { int partNum = 0; - long remainingBytes = sourceSize % bytesPerSplit; RemoteIterator fileStatusListIterator = fileSystem .listFiles( new Path(inputPath), true); - while (sourceSize > 0) { - TarArchiveOutputStream ar = getTar(fileSystem, outputPath + "_" + partNum + ".tar"); + boolean next = fileStatusListIterator.hasNext(); + while (sourceSize > 0 && next) { + TarArchiveOutputStream ar = getTar(fileSystem, outputPath + "_" + (partNum + 1) + ".tar"); long current_size = 0; - while (fileStatusListIterator.hasNext() && current_size < bytesPerSplit) { + while (next && current_size < bytesPerSplit) { LocatedFileStatus fileStatus = fileStatusListIterator.next(); Path p = fileStatus.getPath(); @@ -125,6 +125,7 @@ public class MakeTar implements Serializable { ar.closeArchiveEntry(); } + next = fileStatusListIterator.hasNext(); } sourceSize = sourceSize - current_size;