Set proper file permisions when a file is created with atomic_move

Fixes #7196