Skip to content

SftpFileStream.Write() buf after SftpFileStream.Seek() #253

Closed
@exidler

Description

@exidler

Since 2016.1.0-beta1, when SftpFileStream.Write() data corruption bug fixed, new bug become.
SftpFileStream.Seek() does not move .Write position.
Test example:

            var buf = Encoding.UTF8.GetBytes("123456");
            var ws = sftp.OpenWrite(path);
            ws.Write(buf, 0, 3);
            ws.Close();
            ws = sftp.OpenWrite(path);
            ws.Seek(3, SeekOrigin.Begin);
            ws.Write(buf, 3, 3);
            ws.Close();
            var text = sftp.ReadAllText(path, Encoding.UTF8);
            Console.WriteLine($"Written '{Encoding.UTF8.GetString(buf)}', read '{text}'");

produce output

Written '123456', read '456'

but correct

Written '123456', read '123456'

Small change in SftpFileStream.cs fix the problem, but need to validate solution.
SftpFileStream-WriteSeek-fix.txt

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions