mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-24 00:50:44 +00:00
* fix(sftp): raise upload WRITE fanout for higher throughput Increase UPLOAD_TRANSFER_CONCURRENCY from 8 to 32 so resumable and fastPut uploads keep ~1MB in flight (32 × 32KB). Keeps the safe 32KB packet size from #2022 while closing most of the gap with ssh2/Electerm defaults on multi-ms RTT paths (#2449). * fix(sftp): never fall straight into serial WriteStream uploads Serial ssh2 WriteStream/put is RTT-bound (one 32KB WRITE at a time) and is the usual cause of sub-MB/s speeds, not the fanout setting alone. - Prefer concurrent WRITE ranges on an isolated channel, then fastPut, then concurrent ranges on the shared browse channel; serial stream is last resort only. - Do not swallow post-upload size/content verification into fallback. - uploadLocal and memory-buffer progress uploads use fastPut with the configured fanout instead of serial put. - Add a regression test that sudo/shared sessions stay pipelined. * fix(sftp): fail closed instead of serial WriteStream fallback Align with OpenSSH/Electerm/WinSCP: default SFTP uploads stay on pipelined WRITE strategies only. When concurrent isolated, fastPut, and concurrent-shared all fail, throw the last error — do not crawl via serial createWriteStream/put (RTT-bound, #2449). uploadLocal and writeSftpBinaryWithProgress require fastPut; no silent serial put path. Tests assert createWriteStream is never invoked on forced concurrent failure. * fix(sftp): restore pipelined upload on session-backed clients Session-backed SFTP clients (openForSession / terminal reuse) are not ssh2-sftp-client instances and lacked client.fastPut after serial put was removed. Expose fastPut via the raw channel and route uploadLocal / writeSftpBinaryWithProgress through pipelinedUploadLocalFile so session-backed paths keep concurrency fanout. * fix(sftp): make pipelined fastPut abortable and throttle progress Address codex review on the upload fanout PR: - Prefer a disposable SFTP channel for cancelable uploads so cancelSftpUpload / AbortSignal can end the transfer immediately. - Honor abort signals for session-backed fastPut instead of ignoring them after the call starts. - Restore 100ms / 1MB progress throttling for binary-with-progress fastPut step callbacks. * fix(sftp): wait for shared-channel fastPut to settle on abort When abort uses a non-disposable browse/sudo SFTP channel, do not reject until fastPut's callback fires so temp/staged cleanup cannot race in-flight WRITEs. Disposable channels still end immediately. * fix(sftp): harden fastPut abort, channel errors, and pause ads Codex re-review fixes: - Attach SFTP channel error listeners during fastPut to avoid unhandled EventEmitter crashes on disposable channels. - Wait for fastPut callback (with short force timeout) after disposable channel abort so temp files are not unlinked while still open. - Mark pause unsupported during transferBridge fastPut fallback; restore pause ads for concurrent-shared. - Create AbortController before staging ArrayBuffer to disk and pass signal to writeFile. * fix(sftp): settle fastPut after errors and verify fastPut content Codex P2 follow-ups: - Channel errors during fastPut wait for the callback or a short force timeout before settling (same pattern as cancel) so temp files are not unlinked while still open. - transferBridge uploadViaFastPut uses the same settle discipline so fallback strategies do not overlap a still-running isolated fastPut. - Resumable fastPut fallback captures and rechecks a local content fingerprint before promoting success. * fix(sftp): reset fastPut checkpoint and verify staged size Codex re-review: - After isolated fastPut fails, reset checkpointBytes so concurrent-shared does not resume past non-contiguous progress holes. - Rethrow noTransferFallback/sourceChanged after fastPut fingerprint check. - uploadLocal verifies staged remote size against local before rename. * fix(sftp): avoid hang on cancelled close and unsafe fastPut checkpoints - Skip/timeout remote CLOSE after disposable channel abort/failure so concurrent upload finally does not hang waiting on a dead channel. - fastPut progress updates UI without advancing durable checkpointBytes (non-contiguous chunk progress is not crash-safe resume state). * fix(sftp): address remaining remote Codex review notes - Fall back to the shared browse SFTP channel when opening a disposable upload channel fails (MaxSessions / subsystem refused), unless aborted. - Force-settle concurrent range uploads after cancel if in-flight WRITEs stall on a non-disposable shared channel (2s grace). * fix(sftp): bound shared-channel fastPut cancel with force-settle Shared browse/sudo channels cannot call sftp.end() on abort without killing the session, but a stalled fastPut callback must still settle. Schedule the same 2s force-finish used for disposable channels, and cover it with a stall test that asserts the shared channel is not ended. * fix(sftp): force-settle shared-channel fastPut on channel error Shared browse/sudo channels cannot be ended on error, but a stalled fastPut callback after an error event still must not hang forever. Schedule the same 2s force-finish for shared-channel errors without calling sftp.end(), and cover it with a stall regression test. * fix(sftp): stage binary uploads and cleanup shared-channel cancel writeSftpBinaryWithProgress now uploads to a remote .part path and renames into place, so a stalled shared-channel fastPut cannot keep mutating the final destination after cancel returns. Shared-channel force-settle also best-effort unlinks the in-progress remote target without ending the browse/sudo session. * fix(sftp): harden staged upload replace semantics Default to stage+rename for cancel-safe finals, but: - write symlinks in-place so the link node is not replaced - restore previous mode bits after rename overwrite - fall back to in-place when creating a .part is permission-denied Covers mode restore, symlink, and parent-dir permission regressions. * fix(sftp): encode after staging names; never unlink finals - Build stage/backup names from the logical path, then encode (GB18030-safe) - Existing files/symlinks write in-place to preserve inode/metadata - Shared-channel force-settle only unlinks .netcatty-upload-*.part paths * fix(sftp): keep AbortSignal aborted in dispose cancel handler When cancel replaces transferControl.abort for a disposable channel, also abort the AbortController so staged rename/promotion cannot complete after the UI has already cancelled the upload. * fix(sftp): stage regular overwrites; throttle fastPut progress Regular files always stage+rename (cancel cannot mutate finals on shared channels) and restore mode after promotion. Symlinks stay in-place. Clip stage/backup basenames to NAME_MAX and stop forcing every fastPut step progress event through IPC. * fix(sftp): tighten staging plan and permission fallback - Without native lstat, existing paths write in-place to avoid clobbering links - Permission fallback uses SFTP/error codes only (not message substrings) - Cover size-mismatch paths whose names contain words like "access" * fix: address Codex review on PR #2452 * fix(sftp): write SCP uploads through existing symlinks in-place SCP stage+rename was replacing the symlink node itself. Detect symlink destinations first and upload through them so the link target is updated. * fix(sftp): drain shared writes before cleanup * fix(sftp): track generated upload stages explicitly * fix(sftp): preserve upload recovery paths --------- Co-authored-by: netcatty-bot <308658023+netcatty-bot@users.noreply.github.com>
32 lines
1.5 KiB
JavaScript
32 lines
1.5 KiB
JavaScript
"use strict";
|
|
|
|
// Keep ssh2's default 32KB request size. Some SFTP servers mishandle larger
|
|
// requests and can silently produce truncated/corrupt files (GitHub #2022).
|
|
const TRANSFER_CHUNK_SIZE = 32 * 1024;
|
|
|
|
// Upload fanout: 32 parallel 32KB WRITE requests (~1MB in flight). Measured
|
|
// against real hosts (public ~38ms RTT and LAN ~13ms RTT): concurrency 8 left
|
|
// multi-MB/s on the table; 32 matched Electerm/ssh2-class throughput without
|
|
// the occasional stalls seen at a full 64 on higher-latency paths. Uploads still
|
|
// use an isolated SFTP channel / dedicated transfer session so interactive
|
|
// terminal traffic is not starved (GitHub #1507, #2449).
|
|
const UPLOAD_TRANSFER_CONCURRENCY = 32;
|
|
|
|
// Downloads need a larger request window on high-latency proxy paths. 64 is
|
|
// ssh2's fastGet default and, with the safe 32KB request size, restores the 2MB
|
|
// in-flight window Netcatty used before the shared chunk-size fix in #2030.
|
|
const DOWNLOAD_TRANSFER_CONCURRENCY = 64;
|
|
// Only one file per SFTP session gets the 64-request fast path. Concurrent
|
|
// files keep moving through the compatible stream path instead of multiplying
|
|
// fastGet pressure or overriding the user's file-transfer concurrency.
|
|
// (FileZilla/WinSCP-style multi-file parallelism is handled by the per-host
|
|
// file admission queue above this layer.)
|
|
const FAST_DOWNLOAD_CHANNELS_PER_SESSION = 1;
|
|
|
|
module.exports = {
|
|
DOWNLOAD_TRANSFER_CONCURRENCY,
|
|
FAST_DOWNLOAD_CHANNELS_PER_SESSION,
|
|
TRANSFER_CHUNK_SIZE,
|
|
UPLOAD_TRANSFER_CONCURRENCY,
|
|
};
|