sanketbajoria / ssh2-promise

ssh with promise/async await and typescript support
https://www.npmjs.com/package/ssh2-promise
MIT License
148 stars 24 forks source link

readData/writeData invalid #31

Closed jeffrson closed 3 years ago

jeffrson commented 5 years ago

Apparently there should be methods readData and writeData.

I don't know, whether has SSH2 renamed these or why these methods don't exist. In any case it seems they should be called read and write, respectively.

This bug is critical, because readData/writeData are unusable, as are read/write.

BTW, what are readFileData and writeFileData?

jeffrson commented 5 years ago

AFAICT after some research, the difference between read & readData is caused by SSH2.sftp returning an SFTPWrapper, which uses read instead of readData and write instead of writeData.

jeffrson commented 5 years ago

Please check the PR and release a new version on npm!

BTW, the tests cannot be run, because it's missing a file:

yarn run test yarn run v1.16.0 $ ts-node node_modules/jasmine/bin/jasmine Error: ENOENT: no such file or directory, open './spec/fixture.json' ...

sanketbajoria commented 4 years ago

@jeffrson

Sorry for late reply, got stuck with other work

Yes, test cannot be run right now, I am working on 'test' branch, which contain docker image, against which we could run our test cases

Currently, i am trying to integrate travis ci fully. Once, done, i will merge it with master.

Apart from this i didn't understand the 'read' and 'write' requirement. If you open below link https://github.com/mscdex/ssh2-streams/blob/master/SFTPStream.md

in this page, clearly, readData and writeData is being used, that's why i have used the same name.

jeffrson commented 4 years ago

Well, the problem is, your library isn't really using that SFTPStream.

Instead, in sshConnection (https://github.com/sanketbajoria/ssh2-promise/blob/master/src/sshConnection.ts#L85) it receives an instance of a class called SFTPWrapper (https://github.com/mscdex/ssh2/blob/master/lib/client.js#L888), which replaces readData/writeData by read/write, respectively (https://github.com/mscdex/ssh2/blob/master/lib/SFTPWrapper.js#L44).

Hence, readData/writeData don't exist in sftp(), which it why it fails, when these are called.

I'm sorry the initial post is a bit confusing. But at that time I didn't know enough about the background. Just using "readData" had been failing for me.