Copy temp dmg to ensure that the file is not locked

This commit is contained in:
Dmitry Vedenko 2024-03-26 13:20:11 +03:00
parent 6eb5219d0d
commit 0c0c7d9e58
No known key found for this signature in database
GPG Key ID: F4C37A6204F983A2
2 changed files with 13 additions and 3 deletions

File diff suppressed because one or more lines are too long

View File

@ -201,18 +201,28 @@ async function convertDMG(tempDmgPath, dmgPath) {
for (let attempt = 1; attempt < maxAttempts; ++attempt) {
try {
if (fs.existsSync(dmgPath)){
if (fs.existsSync(dmgPath)) {
fs.rmSync(dmgPath);
}
const newTempPath = tempDmgPath + '.new';
if (fs.existsSync(newTempPath)) {
fs.rmSync(newTempPath);
}
await fs.promises.copyFile(tempDmgPath, newTempPath);
await helpers.execWithLog('hdiutil', [
'convert', tempDmgPath,
'convert', newTempPath,
'-format', 'UDZO',
'-imagekey',
'zlib-level=9',
'-o', dmgPath
]);
fs.rmSync(newTempPath);
return;
} catch (err) {
helpers.error(err.message);