Fail a download whose file server stops sending

The data socket had no read timeout, so a file server that went quiet
left the transfer, and its thread, waiting until the user cancelled.
Thirty seconds without data now fails it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-25 10:55:56 +00:00
parent 48a0032848
commit ae8d1f7083

View File

@@ -46,6 +46,8 @@ import java.util.function.Supplier;
public final class FileTransferManager {
private static final int CONNECT_TIMEOUT_MS = 15_000;
/** How long a download may go without receiving anything before it counts as failed. */
private static final int STALL_TIMEOUT_MS = 30_000;
private static final int BUFFER_SIZE = 64 * 1024;
/** How long to wait for the server's {@code notifystart*} reply after an {@code ftinit*}. */
private static final long NEGOTIATE_TIMEOUT_MS = 15_000;
@@ -406,6 +408,7 @@ public final class FileTransferManager {
Socket socket = new Socket();
socket.connect(new InetSocketAddress(resolveHost(params.getFileServerHost()),
params.getFileServerPort()), CONNECT_TIMEOUT_MS);
socket.setSoTimeout(STALL_TIMEOUT_MS);
return socket;
}