@@ -1418,75 +1418,13 @@ get_wal_file(const char *from_path, const char *to_path)
14181418 * but created in process of backup, such as stream XLOG files,
14191419 * PG_TABLESPACE_MAP_FILE and PG_BACKUP_LABEL_FILE.
14201420 */
1421- bool
1421+ void
14221422calc_file_checksum (pgFile * file )
14231423{
1424- FILE * in ;
1425- size_t read_len = 0 ;
1426- int errno_tmp ;
1427- char buf [BLCKSZ ];
1428- struct stat st ;
1429- pg_crc32 crc ;
1430-
14311424 Assert (S_ISREG (file -> mode ));
1432- INIT_TRADITIONAL_CRC32 (crc );
1433-
1434- /* reset size summary */
1435- file -> read_size = 0 ;
1436- file -> write_size = 0 ;
1437-
1438- /* open backup mode file for read */
1439- in = fopen (file -> path , PG_BINARY_R );
1440- if (in == NULL )
1441- {
1442- FIN_TRADITIONAL_CRC32 (crc );
1443- file -> crc = crc ;
1444-
1445- /* maybe deleted, it's not error */
1446- if (errno == ENOENT )
1447- return false;
1448-
1449- elog (ERROR , "cannot open source file \"%s\": %s" , file -> path ,
1450- strerror (errno ));
1451- }
1452-
1453- /* stat source file to change mode of destination file */
1454- if (fstat (fileno (in ), & st ) == -1 )
1455- {
1456- fclose (in );
1457- elog (ERROR , "cannot stat \"%s\": %s" , file -> path ,
1458- strerror (errno ));
1459- }
1460-
1461- for (;;)
1462- {
1463- read_len = fread (buf , 1 , sizeof (buf ), in );
1464-
1465- if (read_len == 0 )
1466- break ;
1467-
1468- /* update CRC */
1469- COMP_TRADITIONAL_CRC32 (crc , buf , read_len );
1470-
1471- file -> write_size += read_len ;
1472- file -> read_size += read_len ;
1473- }
1474-
1475- errno_tmp = errno ;
1476- if (!feof (in ))
1477- {
1478- fclose (in );
1479- elog (ERROR , "cannot read backup mode file \"%s\": %s" ,
1480- file -> path , strerror (errno_tmp ));
1481- }
1482-
1483- /* finish CRC calculation and store into pgFile */
1484- FIN_TRADITIONAL_CRC32 (crc );
1485- file -> crc = crc ;
1486-
1487- fclose (in );
14881425
1489- return true;
1426+ file -> crc = pgFileGetCRC (file -> path , false, false, & file -> read_size );
1427+ file -> write_size = file -> read_size ;
14901428}
14911429
14921430/*
@@ -1779,11 +1717,11 @@ fileEqualCRC(const char *path1, const char *path2, bool path2_is_compressed)
17791717 else
17801718#endif
17811719 {
1782- crc2 = pgFileGetCRC (path2 );
1720+ crc2 = pgFileGetCRC (path2 , false, true, NULL );
17831721 }
17841722
17851723 /* Get checksum of original file */
1786- crc1 = pgFileGetCRC (path1 );
1724+ crc1 = pgFileGetCRC (path1 , false, true, NULL );
17871725
17881726 return EQ_CRC32C (crc1 , crc2 );
17891727}
0 commit comments