Я пытаюсь загрузить файл, но он продолжает прерываться, и я понятия не имею, почему. Я не могу найти какую-либо информацию о том, как отладить причину, по которой она была прервана.Electron will-download продолжает прерваться
Вот где я спасаю файл:
C: \ Users \ rnaddy \ AppData \ Roaming \ Тахионный \ игры \ murware \ супер-цепной реакции \ web.zip
window.webContents.session.on('will-download', (event, item, webContents) => {
let path = url.parse(item.getURL()).pathname;
let dev = path.split('/')[3] || null;
let game = path.split('/')[4] || null;
if (!dev && !game) {
item.cancel();
} else {
item.setSavePath(Settings.fileDownloadLocation(dev, game, 'web'));
item.on('updated', (event, state) => {
let progress = 0;
if (state == 'interrupted') {
console.log('Download is interrupted but can be resumed');
} else if (state == 'progressing') {
progress = item.getReceivedBytes()/item.getTotalBytes();
if (item.isPaused()) {
console.log('Download is paused');
} else {
console.log(`Received bytes: ${item.getReceivedBytes()}; Progress: ${progress.toFixed(2)}%`);
}
}
});
}
});
Вот мой слушатель, который будет вызывать выше:
ipcMain.on(name, (evt) => {
window.webContents.downloadURL('http://api.gamesmart.com/v2/download/murware/super-chain-reaction');
});
Вот вывод, что я получаю в моей консоли:
Received bytes: 0; Progress: 0.00%
Received bytes: 233183; Progress: 0.02%
Download is interrupted but can be resumed
У меня есть файл установки хост:
127.0.0.1 api.gamesmart.com
Когда я пытаюсь открыть путь http://api.gamesmart.com/v2/download/murware/super-chain-reaction в хроме, файл загрузки просто отлично в мою папку Downloads. Итак, что вызывает это?