Skip to content
This repository has been archived by the owner on Feb 5, 2022. It is now read-only.

Misleading error message "... is not a Buffer" and strange path #32

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,22 @@ Client.prototype.write = function(options, callback) {

sftp.open(destination, 'w', attrs, function(err, handle) {
if (err) {
// destination is directory
// destination could be a directory
// it eventually can't be accessible
// to prevent getting a destination like:
// /pubic/app.js/app.js
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"public" ? :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

of course i ment public :-D 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@christianor I think @Narigo has found a typo. It is public, not pubic.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i fixed the typo

// we use path.dirname when joining
destination = path.join(
destination, path.basename(options.source)
path.dirname(destination), path.basename(options.source)
);
destination = unixy(destination);

// for emit write event
options.destination = destination;
sftp.open(destination, 'w', attrs, function(err, handle) {
if (err)
throw new Error('There was an error opening the destination: ' + destination
+ '\n' + err + '\n please check the destination file or folder for accessibility');
_write(handle);
});
} else {
Expand Down