From 736815bebc732aa97efaad70a7c2b3b4f4e77941 Mon Sep 17 00:00:00 2001 From: Mateusz Warowny Date: Wed, 9 Oct 2019 16:03:03 +0100 Subject: [PATCH] JAL-3066 Fix log files retrieval. --- src/jalview/ws/slivkaws/SlivkaWSInstance.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) 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 -- 1.7.10.2