Change downloaded file permission based on umask
_The documentation is not available anymore as the PR was closed or merged._
This PR changes the permission of downloaded files to cache, so that the umask is taken into account.

Related to:
- #2157

Fix #5799.

CC: @stas00 