Skip to content

Commit

Permalink
Use _chsize_s on windows to grow file
Browse files Browse the repository at this point in the history
Looks like "seek after file end and write" doesn't work
correctly in Windows. We have to grow file before.

Met occasionally on GitHub actions run. Could not reproduce
locally.
  • Loading branch information
funny-falcon committed Apr 18, 2023
1 parent b7551bd commit d672166
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/utils/file.c
Expand Up @@ -2717,6 +2717,14 @@ fio_send_file_write(FILE* out, send_file_state* st, char *buf, size_t len)
if (len == 0)
return true;

#ifdef WIN32
if (st->read_size > st->write_size &&
_chsize_s(fileno(out), st->read_size) != 0)
{
elog(WARNING, "Could not change file size to %lld: %m", st->read_size);
return false;
}
#endif
if (st->read_size > st->write_size &&
fseeko(out, st->read_size, SEEK_SET) != 0)
{
Expand Down

0 comments on commit d672166

Please sign in to comment.