From 67762a976b684d8dab8685f0382f0efb3f00f1fd Mon Sep 17 00:00:00 2001 From: crschnick Date: Fri, 12 Jul 2024 13:51:33 +0000 Subject: [PATCH] Browser timeout fixes --- .../io/xpipe/app/browser/BrowserStatusBarComp.java | 4 ++-- .../java/io/xpipe/core/process/CommandControl.java | 3 +++ .../io/xpipe/core/store/ConnectionFileSystem.java | 11 +++++------ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/browser/BrowserStatusBarComp.java b/app/src/main/java/io/xpipe/app/browser/BrowserStatusBarComp.java index b350ea07..88a2b08c 100644 --- a/app/src/main/java/io/xpipe/app/browser/BrowserStatusBarComp.java +++ b/app/src/main/java/io/xpipe/app/browser/BrowserStatusBarComp.java @@ -58,8 +58,8 @@ public class BrowserStatusBarComp extends SimpleComp { return null; } else { var expected = p.expectedTimeRemaining(); - var show = (p.getTotal() > 50_000_000 && p.elapsedTime().compareTo(Duration.of(200, ChronoUnit.MILLIS)) > 0) || expected.toMillis() > 5000; - var time = show ? HumanReadableFormat.duration(p.expectedTimeRemaining()) : "..."; + var show = p.elapsedTime().compareTo(Duration.of(200, ChronoUnit.MILLIS)) > 0 && (p.getTotal() > 50_000_000 || expected.toMillis() > 5000); + var time = show ? HumanReadableFormat.duration(p.expectedTimeRemaining()) : ""; return time; } }); diff --git a/core/src/main/java/io/xpipe/core/process/CommandControl.java b/core/src/main/java/io/xpipe/core/process/CommandControl.java index 7849cf08..1e4dc607 100644 --- a/core/src/main/java/io/xpipe/core/process/CommandControl.java +++ b/core/src/main/java/io/xpipe/core/process/CommandControl.java @@ -8,6 +8,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.nio.charset.Charset; +import java.time.Duration; import java.util.Optional; import java.util.function.Consumer; import java.util.function.Function; @@ -59,6 +60,8 @@ public interface CommandControl extends ProcessControl { OutputStream startExternalStdin() throws Exception; + public void setExitTimeout(Duration duration); + boolean waitFor(); CommandControl withCustomCharset(Charset charset); diff --git a/core/src/main/java/io/xpipe/core/store/ConnectionFileSystem.java b/core/src/main/java/io/xpipe/core/store/ConnectionFileSystem.java index 6073bd7b..56dc9fdf 100644 --- a/core/src/main/java/io/xpipe/core/store/ConnectionFileSystem.java +++ b/core/src/main/java/io/xpipe/core/store/ConnectionFileSystem.java @@ -1,13 +1,13 @@ package io.xpipe.core.store; +import com.fasterxml.jackson.annotation.JsonIgnore; import io.xpipe.core.process.CommandBuilder; import io.xpipe.core.process.ShellControl; - -import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Getter; import java.io.InputStream; import java.io.OutputStream; +import java.time.Duration; import java.util.List; import java.util.Optional; import java.util.stream.Stream; @@ -53,10 +53,9 @@ public class ConnectionFileSystem implements FileSystem { @Override public OutputStream openOutput(String file, long totalBytes) throws Exception { - return shellControl - .getShellDialect() - .createStreamFileWriteCommand(shellControl, file, totalBytes) - .startExternalStdin(); + var cmd = shellControl.getShellDialect().createStreamFileWriteCommand(shellControl, file, totalBytes); + cmd.setExitTimeout(Duration.ofMillis(Long.MAX_VALUE)); + return cmd.startExternalStdin(); } @Override