fix(0.8.10): Fix rw_upload parameter sequencing (remote, local) - #24
Merged
Merged
Conversation
…expects fastPut(local, remote)
Root cause of the reported bug ('ENOENT ... open C:\home\...'): rw_upload called
sftp.fastPut(rp, lp), but ssh2's contract is fastPut(LOCAL path, REMOTE path) —
the reverse of fastGet(remotePath, localPath). ssh2 therefore opened the REMOTE
path as a local file, which on Windows resolves /home/... against the current
drive, even when localPath was perfectly valid. The tool could never have worked
since its introduction. rw_push/rw_sync/rw_download use writeFile/fastGet with
correct argument order and were unaffected.
- lib/index.js: call fastPut(lp, rp); rename the SFTP wrapper params to (lp, p)
so the argument order matches the ssh2 contract.
- test/upload.test.js (new): hermetic ssh2.Client prototype patch drives the
real apply() + pool + SFTP wrapper and asserts fastPut receives
(local, remote); verified to fail against the old order.
- test/helpers.js: the MemFs fastPut mock encoded the same swapped order (any
test built on it could never catch this class of bug) - corrected to the real
contract.
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.
This patch should fix the previous errors in rw_upload due to incorrect parameter sequence in calling ssh2 fastPut() method.
The issue is previously hidden by that nowadays agents could come up with bypassing commands, yet they induce extra token cost and distractions. After the fix the rw_upload behaves as intended without requiring following calls.