Skip to content

Commit

Permalink
Handles file not found on FTP
Browse files Browse the repository at this point in the history
Some FTP servers return an empty array on stat.
  • Loading branch information
JbIPS committed Jun 10, 2018
1 parent cfeef13 commit f71112a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/unifile-ftp.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ function callAPI(session, action, client, ...params) {
if(err.code === 530) {
throw new UnifileError(UnifileError.EACCES, 'Invalid credentials');
}
console.log(session, action, client, params);

This comment has been minimized.

Copy link
@lexoyo

lexoyo Jun 11, 2018

Member

Maybe it is not a good idea to log the session... Logs will contain sensitive info right?

This comment has been minimized.

Copy link
@lexoyo

lexoyo Jun 11, 2018

Member

cc @JbIPS

throw new UnifileError(UnifileError.EIO, err.message);
})
.then((result) => {
Expand Down Expand Up @@ -198,6 +199,8 @@ class FtpConnector {
stat(session, path, ftpSession) {
return callAPI(session, 'ls', ftpSession, path)
.then((entries) => {
// Not found
if(entries.length === 0) throw new UnifileError(UnifileError.ENOENT, 'Not found');
// It's a file
if(entries.length === 1) return toFileInfos(entries[0]);
// It's a folder
Expand Down

1 comment on commit f71112a

@JbIPS
Copy link
Collaborator Author

@JbIPS JbIPS commented on f71112a Jun 11, 2018

Choose a reason for hiding this comment

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

Very sensitive... my bad, I shouldn't push hotfixes past midnight 😌.

Thank you for the catch, I'll fix that in the next commit.

Please sign in to comment.