Skip to content

Commit f5c9ab9

Browse files
committed
fix(transfer): self-dial cloned worker on read_range for SFTP/FTP pools
Clone-for-transfer workers in the SFTP and FTP pool kinds honestly start UNCONNECTED (PD-SFTP-1 / PD-FTP-1 contract): each worker self-dials its own connection on first transfer. download() already calls ensure_connected() before using the session, but read_range() did not. The new GUI segmented engine (run_provider_segmented_download from GTC-2) puts the cloned workers into a pool and then drives them via read_range, not download, so the per-worker self-dial never fired and every segmented attempt failed with "Not connected to server". Fix: lift the same self.ensure_connected().await? guard from download() into read_range() on both SFTP and FTP. The call is a no-op when already connected, so the CLI pget_segmented_download path (which pre-connects each worker via create_and_connect) is unaffected, and the existing download() callers keep behaving identically. Surfaced by live-WAN validation of GTC-1 / GTC-2 against the axpbuntu lab (see tests/gtc/reports/20260520T113538Z_gui_wan/). After the fix, SFTP segmented byte-identical at 2.52x, FTP at 1.71x, both inside the parity-oracle spec band.
1 parent 82bc910 commit f5c9ab9

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

src-tauri/src/providers/ftp.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,6 +1513,12 @@ impl StorageProvider for FtpProvider {
15131513
)));
15141514
}
15151515

1516+
// PD-FTP-1 mirror of the SFTP path: clone-for-transfer workers
1517+
// start unconnected and self-dial on first transfer. The GUI
1518+
// segmented engine calls `read_range` directly on the pool
1519+
// worker, so without this self-dial every segmented download
1520+
// against a clone pool fails with `Not connected`.
1521+
self.ensure_connected().await?;
15161522
let stream = self.stream_mut()?;
15171523

15181524
stream

src-tauri/src/providers/sftp.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1971,6 +1971,13 @@ impl StorageProvider for SftpProvider {
19711971
offset: u64,
19721972
len: u64,
19731973
) -> Result<Vec<u8>, ProviderError> {
1974+
// PD-SFTP-1: clone-for-transfer workers start unconnected and
1975+
// re-dial on first transfer. `download()` already does this; the
1976+
// segmented engine (`run_provider_segmented_download`) calls
1977+
// `read_range` directly on the pool worker, so the same self-dial
1978+
// must happen here or every segmented download against a clone
1979+
// pool fails with `Not connected`.
1980+
self.ensure_connected().await?;
19741981
let sftp = self
19751982
.sftp
19761983
.as_ref()

0 commit comments

Comments
 (0)