fix: apply correct perms to cached file (instead of 0600).

Tempfiles are created with a default chmod of 0600. This is fine for most single-user setups, but can cause problem is the file is expected to be created in accordance to the umask.

This patches this issue by setup the permissions of the file *after it's been moved to a permanent file*.
Basic permissions for files are 0666, to which we substract the umask to obtain the expected permissions.