Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit04f0097

Browse files
committed
[refer #PGPRO-1745] Check for existing file in fio_gzopen
1 parent3622aeb commit04f0097

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

‎src/data.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,13 +1702,12 @@ fileEqualCRC(const char *path1, const char *path2, bool path2_is_compressed)
17021702

17031703
for (;;)
17041704
{
1705-
intread_len=0;
1706-
read_len=fio_gzread(gz_in,buf,sizeof(buf));
1705+
intread_len=fio_gzread(gz_in,buf,sizeof(buf));
17071706
if (read_len <=0&& !fio_gzeof(gz_in))
17081707
/* An error occurred while reading the file */
17091708
elog(ERROR,
1710-
"Cannot compare WAL file \"%s\" with compressed \"%s\"",
1711-
path1,path2);
1709+
"Cannot compare WAL file \"%s\" with compressed \"%s\": %d",
1710+
path1,path2,read_len);
17121711

17131712
COMP_FILE_CRC32(true,crc2,buf,read_len);
17141713
if (fio_gzeof(gz_in)||read_len==0)

‎src/utils/file.c‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,14 @@ fio_gzopen(char const* path, char const* mode, int level, fio_location location)
768768
if (rc==Z_OK)
769769
{
770770
gz->compress=1;
771-
gz->fd=fio_open(path,O_WRONLY|O_CREAT|O_TRUNC,location);
771+
if (fio_access(path,F_OK,location)==0)
772+
{
773+
elog(LOG,"File %s exists",path);
774+
free(gz);
775+
errno=EEXIST;
776+
returnNULL;
777+
}
778+
gz->fd=fio_open(path,O_WRONLY |O_CREAT |O_EXCL |PG_BINARY,location);
772779
}
773780
}
774781
else
@@ -780,7 +787,7 @@ fio_gzopen(char const* path, char const* mode, int level, fio_location location)
780787
if (rc==Z_OK)
781788
{
782789
gz->compress=0;
783-
gz->fd=fio_open(path,O_RDONLY,location);
790+
gz->fd=fio_open(path,O_RDONLY |PG_BINARY,location);
784791
}
785792
}
786793
if (rc!=Z_OK)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp