FluentFTP icon indicating copy to clipboard operation
FluentFTP copied to clipboard

Override Read(Span), ReadAsync(Memory), Write(ROS), WriteAsync(ROM) in streams

Open bbowyersmyth opened this issue 1 year ago • 3 comments

Available in NETSTANDARD2_1 and NET5_0_OR_GREATER, the base class functions in Stream for backwards compatibility rent an array and copy the span to it and then call the old array based functions.

As an optimization FtpDataStream and FtpSocketStream can override these functions and pass the call directly onto the wrapped stream.

public override void Write(ReadOnlySpan<byte> buffer) {
    if (BaseStream == null) {
        return;
     }

    BaseStream.Write(buffer);
    m_lastActivity = DateTime.UtcNow;
}

Like how the old FtpClient has been changed https://github.com/dotnet/runtime/blob/main/src/libraries/System.Net.Requests/src/System/Net/FtpDataStream.cs#L231

bbowyersmyth avatar May 07 '24 23:05 bbowyersmyth

I would appreciate it if you could spare the time and make a PR.

robinrodricks avatar May 08 '24 13:05 robinrodricks

I've put up a draft PR but I need to sort out a machine I can run the docker tests on

bbowyersmyth avatar May 08 '24 23:05 bbowyersmyth

Thanks a lot, will review it.

robinrodricks avatar May 09 '24 04:05 robinrodricks