From 4390cd4a904265c5ece7456c8ad40815aff95e18 Mon Sep 17 00:00:00 2001 From: Mark Wylde Date: Sun, 14 May 2023 15:44:21 +0100 Subject: [PATCH] Make sshCopyFile copy chmod too --- lib/utils/sshCopyFile.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/utils/sshCopyFile.js b/lib/utils/sshCopyFile.js index 3dec15e..27b801a 100644 --- a/lib/utils/sshCopyFile.js +++ b/lib/utils/sshCopyFile.js @@ -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);