Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
await Promise.all(files.map(async file => {
const fullPath = path.posix.join(remotePath, file.filename);
let stat: SSH2Stats;
try {
stat = await this.queuifiedSftp.lstat(fullPath);
if (stat.isDirectory()) {
await this.queuifiedSftp.readdir(fullPath);
} else {
const buffer = await this.queuifiedSftp.open(fullPath, 'r+');
await this.queuifiedSftp.close(buffer);
}
} catch (err) {
if (err.code === SFTP_STATUS_CODE.PERMISSION_DENIED) {
table.set(file.filename, {remoteStat: 'error', remoteTimestamp: null});
}
return;
}
if (stat) {
table.set(file.filename, {
remoteStat: stat.isDirectory() ? 'dir' : 'file',
remoteTimestamp: stat.mtime
});
}
}));
};