mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-28 13:46:33 +00:00
fixes
This commit is contained in:
parent
fdf8820b5a
commit
aeaa832bdd
@ -106,22 +106,25 @@ export async function sudo(
|
|||||||
});
|
});
|
||||||
|
|
||||||
// we don't spawn directly in the promise otherwise resolving stop the process
|
// we don't spawn directly in the promise otherwise resolving stop the process
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
setInterval(() => {
|
const checkElevation = setInterval(() => {
|
||||||
if (result.status === 'waiting') {
|
if (result.status === 'waiting') {
|
||||||
// Still waiting for user input, don't resolve or reject yet
|
|
||||||
return;
|
return;
|
||||||
} else if (result.status === 'granted') {
|
} else if (result.status === 'granted') {
|
||||||
// User accepted the UAC prompt, process started
|
clearInterval(checkElevation);
|
||||||
resolve({ cancelled: false });
|
resolve({ cancelled: false });
|
||||||
} else if (result.status === 'cancelled') {
|
} else if (result.status === 'cancelled') {
|
||||||
// User cancelled the UAC prompt
|
clearInterval(checkElevation);
|
||||||
resolve({ cancelled: true });
|
resolve({ cancelled: true });
|
||||||
} else {
|
|
||||||
// An error occurred, reject the promise
|
|
||||||
reject(new Error(`Elevation failed: ${result.status}`));
|
|
||||||
}
|
}
|
||||||
}, 300);
|
}, 300);
|
||||||
|
|
||||||
|
// if the elevation didn't occured in 30 seconds we reject the promise
|
||||||
|
setTimeout(() => {
|
||||||
|
clearInterval(checkElevation);
|
||||||
|
reject(new Error('Elevation timeout'));
|
||||||
|
}, 30000);
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(`Can't elevate process ${error}`);
|
throw new Error(`Can't elevate process ${error}`);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user