mirror of
https://github.com/audacity/audacity-actions.git
synced 2025-12-10 03:56:07 -06:00
Retry every hdiutil operation
On newer macOS version hdiutil fails even more often
This commit is contained in:
parent
71e220d61c
commit
5dee4e7a97
2
dist/package/index.js
vendored
2
dist/package/index.js
vendored
File diff suppressed because one or more lines are too long
@ -60,6 +60,11 @@ async function detachImage(mountedPath) {
|
||||
|
||||
for (let attempt = 1; attempt < maxAttempts; ++attempt) {
|
||||
try {
|
||||
if (!fs.existsSync(mountedPath)) {
|
||||
helpers.log(`Image ${mountedPath} already detached`);
|
||||
return;
|
||||
}
|
||||
|
||||
return await helpers.execWithLog('hdiutil', [
|
||||
'detach', mountedPath
|
||||
]);
|
||||
@ -68,35 +73,52 @@ async function detachImage(mountedPath) {
|
||||
await helpers.sleep(2000 * attempt);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
if (!fs.existsSync(mountedPath)) {
|
||||
helpers.log(`Image ${mountedPath} already detached`);
|
||||
return;
|
||||
}
|
||||
|
||||
return await helpers.execWithLog('hdiutil', [
|
||||
'detach', mountedPath, '-force'
|
||||
]);
|
||||
} catch (err) {
|
||||
helpers.error(err.message);
|
||||
throw new Error(`Failed to detach image ${mountedPath}`);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async function attachImage(imagePath, finalizers) {
|
||||
const output = await helpers.getExecOutput('hdiutil', [
|
||||
'attach', imagePath,
|
||||
'-nobrowse',
|
||||
'-noverify',
|
||||
'-noautoopen'
|
||||
]);
|
||||
const maxAttempts = 10;
|
||||
|
||||
const match = /Apple_HFS\s+(.*)\s*$/.exec(output.stdout);
|
||||
const mountedPath = match[1];
|
||||
for (let attempt = 1; attempt < maxAttempts; ++attempt) {
|
||||
try {
|
||||
const output = await helpers.getExecOutput('hdiutil', [
|
||||
'attach', imagePath,
|
||||
'-nobrowse',
|
||||
'-noverify',
|
||||
'-noautoopen'
|
||||
]);
|
||||
|
||||
finalizers.push(async () => {
|
||||
if (fs.existsSync(mountedPath)) {
|
||||
helpers.log(`Detaching image ${imagePath} mounted at ${mountedPath}`);
|
||||
await detachImage(mountedPath);
|
||||
const match = /Apple_HFS\s+(.*)\s*$/.exec(output.stdout);
|
||||
const mountedPath = match[1];
|
||||
|
||||
finalizers.push(async () => {
|
||||
if (fs.existsSync(mountedPath)) {
|
||||
helpers.log(`Detaching image ${imagePath} mounted at ${mountedPath}`);
|
||||
await detachImage(mountedPath);
|
||||
}
|
||||
});
|
||||
|
||||
return mountedPath;
|
||||
} catch (err) {
|
||||
helpers.error(err.message);
|
||||
await helpers.sleep(2000 * attempt);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return mountedPath;
|
||||
throw new Error(`Failed to attach image ${imagePath}`);
|
||||
}
|
||||
|
||||
async function copyFiles(targetDir, appDir, files) {
|
||||
@ -151,17 +173,32 @@ async function createDSStore(mountPath, name) {
|
||||
}
|
||||
|
||||
async function convertDMG(tempDmgPath, dmgPath) {
|
||||
if (fs.existsSync(dmgPath)){
|
||||
fs.rmSync(dmgPath);
|
||||
const maxAttempts = 10;
|
||||
|
||||
for (let attempt = 1; attempt < maxAttempts; ++attempt) {
|
||||
try {
|
||||
if (fs.existsSync(dmgPath)){
|
||||
fs.rmSync(dmgPath);
|
||||
}
|
||||
|
||||
await helpers.execWithLog('hdiutil', [
|
||||
'convert', tempDmgPath,
|
||||
'-format', 'UDZO',
|
||||
'-imagekey',
|
||||
'zlib-level=9',
|
||||
'-o', dmgPath
|
||||
]);
|
||||
|
||||
return;
|
||||
} catch (err) {
|
||||
helpers.error(err.message);
|
||||
await helpers.sleep(2000 * attempt);
|
||||
}
|
||||
}
|
||||
|
||||
await helpers.execWithLog('hdiutil', [
|
||||
'convert', tempDmgPath,
|
||||
'-format', 'UDZO',
|
||||
'-imagekey',
|
||||
'zlib-level=9',
|
||||
'-o', dmgPath
|
||||
]);
|
||||
if (!fs.existsSync(dmgPath)) {
|
||||
throw new Error(`Failed to convert image ${tempDmgPath} to ${dmgPath}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function packageDMG(dmgPath, appPath) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user