Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.on('READ', (reqid, handle, offset, length) => {
const path = handle.toString();
if(reading) {
reading = false;
return sftpStream.status(reqid, SFTP_STATUS_CODE.EOF);
}
reading = true;
if(path === 'empty') sftpStream.data(reqid, null);
else Fs.readFilePromised(handle.toString())
.then((data) => sftpStream.data(reqid, data))
.catch((e) => {
if(e.code === 'ENOENT')
sftpStream.status(reqid, SFTP_STATUS_CODE.NO_SUCH_FILE);
else
sftpStream.status(reqid, SFTP_STATUS_CODE.FAILURE);
});
})
.on('WRITE', (reqid, handle, offset, data) => {