Implicitly overwrite file content

I'm currently programming a tool for downloading stuff from the internet. For the user, it is possible to specify a download folder where all downloaded files are stored.

Assume that the program realizes that it should save the download to a file that already exists - how should it react.

Intuitively I would say that the program should come up with some kind of dialog asking the user whether it should replace the existing file, save the download to another file or ...

However, due to the automatic execution, it is NOT possible to ask the user what should be done (replace, use another file, log error, ...).

So what should be done in such a case?