@@ -1402,9 +1402,15 @@ fio_sync(fio_location location, const char* path)
14021402 }
14031403}
14041404
1405+ enum {
1406+ GET_CRC32_DECOMPRESS = 1 ,
1407+ GET_CRC32_MISSING_OK = 2
1408+ };
1409+
14051410/* Get crc32 of file */
14061411pg_crc32
1407- fio_get_crc32 (fio_location location , const char * file_path , bool decompress )
1412+ fio_get_crc32 (fio_location location , const char * file_path ,
1413+ bool decompress , bool missing_ok )
14081414{
14091415 if (fio_is_remote (location ))
14101416 {
@@ -1417,7 +1423,9 @@ fio_get_crc32(fio_location location, const char *file_path, bool decompress)
14171423 hdr .arg = 0 ;
14181424
14191425 if (decompress )
1420- hdr .arg = 1 ;
1426+ hdr .arg = GET_CRC32_DECOMPRESS ;
1427+ if (missing_ok )
1428+ hdr .arg |= GET_CRC32_MISSING_OK ;
14211429
14221430 IO_CHECK (fio_write_all (fio_stdout , & hdr , sizeof (hdr )), sizeof (hdr ));
14231431 IO_CHECK (fio_write_all (fio_stdout , file_path , path_len ), path_len );
@@ -1428,9 +1436,9 @@ fio_get_crc32(fio_location location, const char *file_path, bool decompress)
14281436 else
14291437 {
14301438 if (decompress )
1431- return pgFileGetCRCgz (file_path , true, true );
1439+ return pgFileGetCRCgz (file_path , true, missing_ok );
14321440 else
1433- return pgFileGetCRC (file_path , true, true );
1441+ return pgFileGetCRC (file_path , true, missing_ok );
14341442 }
14351443}
14361444
@@ -3365,10 +3373,10 @@ fio_communicate(int in, int out)
33653373 break ;
33663374 case FIO_GET_CRC32 :
33673375 /* calculate crc32 for a file */
3368- if (hdr .arg == 1 )
3369- crc = pgFileGetCRCgz (buf , true, true );
3376+ if (( hdr .arg & GET_CRC32_DECOMPRESS ) )
3377+ crc = pgFileGetCRCgz (buf , true, ( hdr . arg & GET_CRC32_MISSING_OK ) != 0 );
33703378 else
3371- crc = pgFileGetCRC (buf , true, true );
3379+ crc = pgFileGetCRC (buf , true, ( hdr . arg & GET_CRC32_MISSING_OK ) != 0 );
33723380 IO_CHECK (fio_write_all (out , & crc , sizeof (crc )), sizeof (crc ));
33733381 break ;
33743382 case FIO_GET_CHECKSUM_MAP :
@@ -3606,9 +3614,9 @@ pioLocalDrive_pioGetCRC32(VSelf, path_t path, bool compressed, err_i *err)
36063614 elog (VERBOSE , "Local Drive calculate crc32 for '%s', compressed=%d" ,
36073615 path , compressed );
36083616 if (compressed )
3609- return pgFileGetCRCgz (path , true, true );
3617+ return pgFileGetCRCgz (path , true, false );
36103618 else
3611- return pgFileGetCRC (path , true, true );
3619+ return pgFileGetCRC (path , true, false );
36123620}
36133621
36143622static bool
@@ -3867,7 +3875,7 @@ pioRemoteDrive_pioGetCRC32(VSelf, path_t path, bool compressed, err_i *err)
38673875 hdr .arg = 0 ;
38683876
38693877 if (compressed )
3870- hdr .arg = 1 ;
3878+ hdr .arg = GET_CRC32_DECOMPRESS ;
38713879 elog (VERBOSE , "Remote Drive calculate crc32 for '%s', hdr.arg=%d" ,
38723880 path , compressed );
38733881
0 commit comments