Regression in g_file_set_contents_full() on win32
There appears to be a regression in g_file_set_contents_full()
which only shows up on Windows. The user sees Failed to load AppStream data: cannot create metadata.xmlb: Failed to write file “C:\Users\xxx\fwupd\var\cache\fwupd\metadata.xmlb”: ftruncate() failed: Permission denied
and digging into the code, the problem seems to be from 3f705ffa where we check errno
.
The issue seems to be that ftruncate()
sets errno
, and g_win32_ftruncate()
(which is _chsize
under the covers) does not. So we end up using the last-set unrelated-to-this-call errno
which in our case is EPERM
.
I can either submit a patch to set errno
in g_win32_ftruncate()
or to shuffle the #ifdef G_OS_WIN32
's around a bit in truncate_file()
-- your choice. Thanks!