Skip to content

Commit

Permalink
Make sshCopyFile copy chmod too
Browse files Browse the repository at this point in the history
  • Loading branch information
markwylde committed May 14, 2023
1 parent 75595e5 commit 4390cd4
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/utils/sshCopyFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,15 @@ export async function sshCopyFile(connection, source, destination, options) {
});

writeStream.on('close', () => {
resolve(`Uploaded: ${sourceFile} -> ${destinationFile}`);
sftp.end();
const sourceFileMode = fs.statSync(sourceFile).mode;
sftp.chmod(destinationFile, sourceFileMode, (err) => {
sftp.end();
if (err) {
reject(`Error setting file permissions: ${err.message}`);
} else {
resolve(`Uploaded: ${sourceFile} -> ${destinationFile}`);
}
});
});

readStream.pipe(writeStream);
Expand Down

0 comments on commit 4390cd4

Please sign in to comment.