Synchronize the file's data on disk while copying

This commit is contained in:
Pierre Pronchery 2020-01-02 20:53:09 +01:00
parent fb9e6d10f4
commit 48534b0c58

View File

@ -624,6 +624,8 @@ static gboolean _channel_out(Copy * copy, GIOChannel * source)
if(g_io_channel_write_chars(source, copy->buf, copy->buf_cnt, &written,
&error) == G_IO_STATUS_ERROR)
return _channel_out_error(copy, source, error);
if(fsync(g_io_channel_get_fd(source)) != 0)
_copy_error(NULL, "fsync", -errno);
if(copy->buf_cnt == sizeof(copy->buf))
g_idle_add(_regular_idle_in, copy); /* read again */
copy->buf_cnt -= written;