JAL-3066 Fix log files retrieval.
authorMateusz Warowny <mmzwarowny@dundee.ac.uk>
Wed, 9 Oct 2019 15:03:03 +0000 (16:03 +0100)
committerMateusz Warowny <mmzwarowny@dundee.ac.uk>
Wed, 9 Oct 2019 15:03:03 +0000 (16:03 +0100)
src/jalview/ws/slivkaws/SlivkaWSInstance.java

index a75046d..a5c809f 100644 (file)
@@ -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<RemoteFile> logFile = client.getJobResults(job.getJobId()).stream()
-        .filter(f -> f.getLabel() == "log").findFirst();
+    List<RemoteFile> files = client.getJobResults(job.getJobId());
+    Optional<RemoteFile> 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<RemoteFile> errLogFile = client.getJobResults(job.getJobId()).stream()
-          .filter(f -> f.getLabel() == "error-log").findFirst();
+      Optional<RemoteFile> 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