Use Promise in "will-download" and block UI


I use Mac OS。I hope to detect the existence of this file in the download directory, if there is no normal download, if there is prompted to re-download and open the directory to choose from.

I use two promises, which are used to detect the existence of this file on the disk, and the prompt exists to allow users to choose to re-download or open.

In the end it did not work, but the main thread’s log is the same as expected. I wrote a simple demo for testing:

thanks very much :pray:


it looks like you are going to override the default download dialog behabior, isn’t it?

you may need to call event.preventDefault() to not use default behavior.

see in


I use the dialog to refine the configuration of downloadItem,not override.
Need to use downloadItem setSavePath, cancel……


I got your point now. from your example code, the default save dialog will be show up during the checking file existing due to it does not wait for promise until it is resolved.

from my knowledge, It is the event emiting. I don’t think you can use promise here.

You may need to implement custome dialog.
for ex,