Skip to content

Commit d672166

Browse files
committed
Use _chsize_s on windows to grow file
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.
1 parent b7551bd commit d672166

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/utils/file.c

+8
Original file line numberDiff line numberDiff line change
@@ -2717,6 +2717,14 @@ fio_send_file_write(FILE* out, send_file_state* st, char *buf, size_t len)
27172717
if (len == 0)
27182718
return true;
27192719

2720+
#ifdef WIN32
2721+
if (st->read_size > st->write_size &&
2722+
_chsize_s(fileno(out), st->read_size) != 0)
2723+
{
2724+
elog(WARNING, "Could not change file size to %lld: %m", st->read_size);
2725+
return false;
2726+
}
2727+
#endif
27202728
if (st->read_size > st->write_size &&
27212729
fseeko(out, st->read_size, SEEK_SET) != 0)
27222730
{

0 commit comments

Comments
 (0)