mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-28 05:36:34 +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
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
setInterval(() => {
|
||||
const checkElevation = setInterval(() => {
|
||||
if (result.status === 'waiting') {
|
||||
// Still waiting for user input, don't resolve or reject yet
|
||||
return;
|
||||
} else if (result.status === 'granted') {
|
||||
// User accepted the UAC prompt, process started
|
||||
clearInterval(checkElevation);
|
||||
resolve({ cancelled: false });
|
||||
} else if (result.status === 'cancelled') {
|
||||
// User cancelled the UAC prompt
|
||||
clearInterval(checkElevation);
|
||||
resolve({ cancelled: true });
|
||||
} else {
|
||||
// An error occurred, reject the promise
|
||||
reject(new Error(`Elevation failed: ${result.status}`));
|
||||
}
|
||||
}, 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) {
|
||||
throw new Error(`Can't elevate process ${error}`);
|
||||
|
Loading…
x
Reference in New Issue
Block a user