fixes #6289: avoids concurrent downloads of files with the same name and destination dir.

One more nitpick - I hate this way of logging (stdout -> debug, stderr -> err) because the way wget logs out ends up with mess (debug is hidden by default, and some ordinary output is usually written to error).

I'd vote for changing this in this PR to stdout-stderr -> debug. Or if you prefer, info.