Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
exidler opened this issue Jul 9, 2017 · 1 comment
Closed

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

exidler opened this issue Jul 9, 2017 · 1 comment
Assignees
Labels

Comments

@exidler
Copy link

exidler commented Jul 9, 2017

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

@drieseng drieseng added this to the 2016.1.0 milestone Jul 17, 2017
@drieseng drieseng added the bug label Jul 17, 2017
@drieseng drieseng self-assigned this Jul 17, 2017
@drieseng
Copy link
Member

This is not a regression in 2016.1.0-beta1, but was actually considered to be "by design" (since as long as I know).

To me this behavior is broken, and I fixed it as part of PR #199.

@drieseng drieseng modified the milestones: 2016-1.0-beta2, 2016.1.0 Jul 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants