mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 16:23:44 +00:00
preserve current permissions
This commit is contained in:
@@ -63,9 +63,15 @@ export class UpdateCommand {
|
|||||||
const zipBuffer = await zipResponse.buffer();
|
const zipBuffer = await zipResponse.buffer();
|
||||||
const zip = new AdmZip(zipBuffer);
|
const zip = new AdmZip(zipBuffer);
|
||||||
const currentDir = this.inPkg ? path.dirname(process.execPath) : __dirname;
|
const currentDir = this.inPkg ? path.dirname(process.execPath) : __dirname;
|
||||||
|
let currentMode: number = null;
|
||||||
|
if (this.inPkg && process.platform !== 'win32') {
|
||||||
|
const stats = fs.statSync(process.execPath);
|
||||||
|
currentMode = stats.mode;
|
||||||
|
}
|
||||||
zip.extractAllTo(currentDir, true);
|
zip.extractAllTo(currentDir, true);
|
||||||
if (process.platform !== 'win32') {
|
if (process.platform !== 'win32') {
|
||||||
fs.chmodSync(path.join(currentDir, 'bw'), '764');
|
const bwFilePath = path.join(currentDir, 'bw');
|
||||||
|
fs.chmodSync(bwFilePath, currentMode != null ? currentMode : '764');
|
||||||
}
|
}
|
||||||
res.title = 'Updated self to ' + tagName + '.';
|
res.title = 'Updated self to ' + tagName + '.';
|
||||||
if (responseJson.body != null && responseJson.body !== '') {
|
if (responseJson.body != null && responseJson.body !== '') {
|
||||||
@@ -91,6 +97,7 @@ export class UpdateCommand {
|
|||||||
res.message = responseJson.body + '\n\n';
|
res.message = responseJson.body + '\n\n';
|
||||||
}
|
}
|
||||||
res.message += 'You can download this update at: ' + downloadUrl + '\n' +
|
res.message += 'You can download this update at: ' + downloadUrl + '\n' +
|
||||||
|
'or run `bw update --self`\n\n' +
|
||||||
'If you installed this CLI through a package manager ' +
|
'If you installed this CLI through a package manager ' +
|
||||||
'you should probably update using its update command instead.';
|
'you should probably update using its update command instead.';
|
||||||
return Response.success(res);
|
return Response.success(res);
|
||||||
|
|||||||
Reference in New Issue
Block a user