g_file_copy(): Ensure G_FILE_COPY_OVERWRITE preserves permissions

We need to close the stream *before* applying the file modes, because
g_file_replace() allocates a temporary file.  At the moment we're
applying the modes to the extant file, then immediately rename()ing
over it with the default perms.

This regressed with commit 166766a89fcd173dcd6ffda11f902029928f7f28.

The real fix here is to have g_file_create_with_info() so that we can
atomically create a file with the permissions we want.

https://bugzilla.gnome.org/show_bug.cgi?id=696014
2 files changed