Skip to content

Commit d6908b3

Browse files
committed
Fix open file mode
1 parent 6114c47 commit d6908b3

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/data.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ restore_data_file(const char *to_path, pgFile *file, bool allow_truncate,
711711
* modified pages for differential restore. If the file does not exist,
712712
* re-open it with "w" to create an empty file.
713713
*/
714-
out = fio_fopen(to_path, PG_BINARY_W "+", FIO_DB_HOST);
714+
out = fio_fopen(to_path, PG_BINARY_R "+", FIO_DB_HOST);
715715
if (out == NULL)
716716
{
717717
int errno_tmp = errno;

src/utils/file.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ FILE* fio_fopen(char const* path, char const* mode, fio_location location)
275275
else
276276
{
277277
f = fopen(path, mode);
278+
if (f == NULL && strcmp(mode, PG_BINARY_R "+") == 0)
279+
f = fopen(path, PG_BINARY_W);
278280
}
279281
return f;
280282
}

0 commit comments

Comments
 (0)