sindresorhus / electron-dl

Simplified file downloads for your Electron app
MIT License
1.16k stars 137 forks source link

Download start even `Save as` not appear #170

Open rtritto opened 3 months ago

rtritto commented 3 months ago

After I trigger download channel, I get the onProgress.progress log before the Save as popup appears.

ipcMain.on('download', async (event: Electron.IpcMainInvokeEvent, downloadUrl: string) => {
  const win = BrowserWindow.getFocusedWindow()!
  try {
    await download(win, downloadUrl, {
      saveAs: true,
      onProgress: (progress) => {
        console.log('onProgress.progress: ', progress);
        mainWindow.webContents.send('download-progress', progress)
      },
      onCompleted: (item) => {
        mainWindow.webContents.send('download-completed', item)
      }
    })
  } catch (error) {
    if (error instanceof CancelError) {
      console.info('item.cancel() was called')
    } else {
      console.error(error)
    }
  }
})

Additional informations: