mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-27 05:06:40 +00:00
patch: fix error handling around file operations
Change-Type: patch
This commit is contained in:
parent
816c45c763
commit
8700cad228
@ -146,12 +146,18 @@ export function SettingsModal({ toggleModal }: SettingsModalProps): any {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const startDiag = async () => {
|
const startDiag = async () => {
|
||||||
|
try {
|
||||||
unlinkSync('/usr/src/diag-data/startup.lock');
|
unlinkSync('/usr/src/diag-data/startup.lock');
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Can't remove diag lock", error)
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
const supUrl: string = readFileSync('/usr/src/diag-data/start.url', {
|
const supUrl: string = readFileSync('/usr/src/diag-data/start.url', {
|
||||||
encoding: 'utf8',
|
encoding: 'utf8',
|
||||||
flag: 'r',
|
flag: 'r',
|
||||||
});
|
});
|
||||||
|
|
||||||
const startRes = await fetch(supUrl, {
|
const startRes = await fetch(supUrl, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({ serviceName: 'diag-runner', force: true }),
|
body: JSON.stringify({ serviceName: 'diag-runner', force: true }),
|
||||||
@ -165,6 +171,10 @@ export function SettingsModal({ toggleModal }: SettingsModalProps): any {
|
|||||||
} else {
|
} else {
|
||||||
setErrorMessage(`${errorMessage} :: ${startRes.statusText}`);
|
setErrorMessage(`${errorMessage} :: ${startRes.statusText}`);
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Error in starting diag", error)
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeDiag = async () => {
|
const removeDiag = async () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user