From: Mateusz Warowny Date: Wed, 9 Oct 2019 15:03:03 +0000 (+0100) Subject: JAL-3066 Fix log files retrieval. X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=736815bebc732aa97efaad70a7c2b3b4f4e77941;p=jalview.git JAL-3066 Fix log files retrieval. --- diff --git a/src/jalview/ws/slivkaws/SlivkaWSInstance.java b/src/jalview/ws/slivkaws/SlivkaWSInstance.java index a75046d..a5c809f 100644 --- a/src/jalview/ws/slivkaws/SlivkaWSInstance.java +++ b/src/jalview/ws/slivkaws/SlivkaWSInstance.java @@ -15,6 +15,7 @@ import java.io.InputStreamReader; import java.util.Arrays; import java.util.EnumMap; import java.util.HashSet; +import java.util.List; import java.util.Optional; import java.util.Set; @@ -71,24 +72,28 @@ public abstract class SlivkaWSInstance extends ServiceWithParameters @Override public final boolean updateJobProgress(WsJob job) throws IOException { - Optional logFile = client.getJobResults(job.getJobId()).stream() - .filter(f -> f.getLabel() == "log").findFirst(); + List files = client.getJobResults(job.getJobId()); + Optional logFile = files.stream() + .filter(f -> f.getLabel().equals("log")).findFirst(); + boolean newContent = false; if (logFile.isPresent()) { InputStream stream = logFile.get().getContent(); long nextChunk = stream.skip(job.getNextChunk()); - job.setnextChunk(nextChunk + appendJobStatus(job, stream)); + int len = appendJobStatus(job, stream); + job.setnextChunk(nextChunk + len); + newContent |= len > 0; } if (failedStates.contains(job.getJobState())) { - Optional errLogFile = client.getJobResults(job.getJobId()).stream() - .filter(f -> f.getLabel() == "error-log").findFirst(); + Optional errLogFile = files.stream() + .filter(f -> f.getLabel().equals("error-log")).findFirst(); if (errLogFile.isPresent()) { - appendJobStatus(job, errLogFile.get().getContent()); + newContent |= appendJobStatus(job, errLogFile.get().getContent()) > 0; } } - return false; + return newContent; } private int appendJobStatus(WsJob job, InputStream stream) throws IOException