ddn.net.sftp.transfer
Bounded pipelined SFTP transfer engine.
SftpDownload schedules multiple positioned READ requests within explicit request-count and byte budgets, reassembles out-of-order and short responses, fills holes left by short reads, and hands ordered data to a caller sink that may accept partial writes.
SftpUpload symmetrically pipelines positioned WRITE requests, pulling bytes from a caller source and tracking every server acknowledgment. Completion means every write was acknowledged; use the capability-checked fsync extension for durability and close the handle afterwards. Accepted data (handed to the protocol) and acknowledged data (confirmed by the server) are reported separately.
Both engines never block and never reenter the caller: progress happens through SftpDownload.pump / SftpUpload.pump, driven alongside the owning client and session pumps.
The remote file is not snapshotted. A file that shrinks while a download runs surfaces as an explicit error rather than silently truncated output; an interrupted upload leaves explicitly uncertain completion, and cleanup closes the handle without replaying writes.
Types 5
Tuning bounds for one pipelined transfer.
The engine never exceeds the client's outstanding-request limit and always clamps the chunk size to the client's effective negotiated limits, regardless of the values configured here.
uint chunkSizeRequested chunk size in bytes; zero selects the client's effective chunk sizeuint maxInFlightMaximum simultaneous outstanding requestsulong byteBudgetMaximum bytes held as in-flight, reordered, or undelivered transfer stateReceives ordered download data. Returning a count smaller than the provided length applies backpressure; the remainder is retained inside the engine's byte budget and redelivered on later pumps.
Produces ordered upload data into the provided buffer. Returning zero marks the source exhausted; partial production is legal and the engine asks again on later pumps.
A bounded pipelined download from an open file handle.
The caller owns the handle; the engine only issues positioned READ requests against it. Cancelling stops scheduling and discards reordered data, but the wire request IDs stay reserved in the client until their late replies arrive.
private SftpClient client_private const(ubyte)[] handle_private ulong length_private SftpDataSink sink_private SftpTransferOptions options_private uint chunk_private ulong expected_private ulong stopOffset_private ulong issueOffset_private ulong eofOffset_private ulong inflightBytes_private ulong delivered_private ulong peakBufferedBytes_private const(ubyte)[] pendingDelivery_private const(ubyte)[][ulong] buffered_private ulong bufferedBytes_private Hole[] holes_private Slot[] outstanding_private SftpProgress progress_private SftpError error_ulong bufferedBytes() @property constReturns: bytes currently buffered as undelivered transfer state.void pump()Advances the download: moves channel bytes, processes completed reads, delivers to the sink, and schedules further requests.void cancel()Cancels the transfer. Outstanding request interest is cancelled and reordered data is discarded; the handle remains open.void processCompletions()void store(ulong offset, const(ubyte)[] data)void deliverPending()void schedule()void commitRange(ulong start, uint length)ulong stopLimit()bool peekReadRange(out ulong start, out uint length)void addHole(ulong start, ulong stop)void checkCompletion()void fail(string message)this(SftpClient client, const(ubyte)[] handle, ulong length,
SftpDataSink sink, SftpTransferOptions options = SftpTransferOptions.init)Constructs a download.SlotHoleprivate SftpClient client_private const(ubyte)[] handle_private SftpDataSource source_private SftpTransferOptions options_private uint chunk_private ulong writeOffset_private ulong pulled_private ulong acknowledged_private ulong outstandingBytes_private ulong peakOutstandingBytes_private bool sourceExhausted_private Slot[] outstanding_private SftpProgress progress_private SftpError error_void pump()Advances the upload: moves channel bytes, records acknowledgments, and schedules further writes from the source.void cancel()Cancels the transfer. Outstanding request interest is cancelled; completion of the already-written prefix stays uncertain until the caller closes the handle.void processAcks()void schedule()void checkCompletion()void fail(string message)this(SftpClient client, const(ubyte)[] handle,
SftpDataSource source,
SftpTransferOptions options = SftpTransferOptions.init)Constructs an upload starting at offset zero.this(SftpClient client, const(ubyte)[] handle, ulong offset,
SftpDataSource source,
SftpTransferOptions options = SftpTransferOptions.init)Constructs an upload starting at an explicit offset.Slot