mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-05-11 13:03:05 +00:00
Error handler for downloading resource and basic WS support
This commit is contained in:
parent
c3e70e7800
commit
f46caaf5e0
@ -34,11 +34,21 @@ ipcMain.on('installed-software-install', async function (event, software) {
|
|||||||
const softwarePath = path.join(app.getAppPath(), software.binary);
|
const softwarePath = path.join(app.getAppPath(), software.binary);
|
||||||
|
|
||||||
if (software.type == 'web') {
|
if (software.type == 'web') {
|
||||||
var response = await fetch(software.resource);
|
try {
|
||||||
await pipeline(
|
var response = await fetch(software.resource);
|
||||||
response.body,
|
if (response.status != 200) {
|
||||||
fs.createWriteStream(softwarePath)
|
throw new Error(`Cannot download file ${software.resource}, response status = ${response.status}`);
|
||||||
);
|
}
|
||||||
|
await pipeline(
|
||||||
|
response.body,
|
||||||
|
fs.createWriteStream(softwarePath)
|
||||||
|
);
|
||||||
|
} catch(error) {
|
||||||
|
event.sender.send('installed-software-installed', {
|
||||||
|
success: false,
|
||||||
|
message: error.message
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const command = `${softwarePath}`;
|
const command = `${softwarePath}`;
|
||||||
@ -46,5 +56,8 @@ ipcMain.on('installed-software-install', async function (event, software) {
|
|||||||
child.on('exit', () => {
|
child.on('exit', () => {
|
||||||
console.log("exited");
|
console.log("exited");
|
||||||
});
|
});
|
||||||
event.sender.send('installed-software-installed', { success: true});
|
|
||||||
|
event.sender.send('installed-software-installed', {
|
||||||
|
success: true
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -23,6 +23,16 @@ export class InstalledSoftwareService {
|
|||||||
binary: 'SolarPuTTY.exe',
|
binary: 'SolarPuTTY.exe',
|
||||||
installation_arguments: ['--only-ask'],
|
installation_arguments: ['--only-ask'],
|
||||||
installed: false
|
installed: false
|
||||||
|
}, {
|
||||||
|
name: 'Wireshark',
|
||||||
|
commands: [
|
||||||
|
'Wireshark.exe'
|
||||||
|
],
|
||||||
|
type: 'web',
|
||||||
|
resource: 'https://1.na.dl.wireshark.org/win64/all-versions/Wireshark-win64-2.6.3.exe',
|
||||||
|
binary: 'Wireshark.exe',
|
||||||
|
installation_arguments: [],
|
||||||
|
installed: false
|
||||||
}];
|
}];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user