Align remote file reads with IO length semantics - #174
Open
OskarEichler wants to merge 2 commits into
Open
Conversation
Author
|
I did another pass over the read state machine and added a regression ensuring that once EOF has been observed, subsequent positive-length reads return |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem: Net::SFTP::Operations::File#read did not follow Ruby IO length semantics: it accepted invalid negative lengths, performed a remote read for zero, returned an empty string instead of nil at positive-length EOF, and could spin when a server returned an empty DATA packet.
Fix: Coerce lengths through to_int, reject negative lengths, return immediately for zero, return nil at EOF for positive reads, and treat empty DATA as EOF.
Regression coverage: Adds focused upstream cases for coercion, invalid lengths, zero-length reads, EOF, and empty DATA. test_file.rb: 38 runs / 120 assertions. Full suite: 439 runs / 1,210 assertions with only the pre-existing Ruby 4 StartTest positional-hash/keyword expectation failure.