@@ -1402,9 +1402,15 @@ fio_sync(fio_location location, const char* path)
1402
1402
}
1403
1403
}
1404
1404
1405
+ enum {
1406
+ GET_CRC32_DECOMPRESS = 1 ,
1407
+ GET_CRC32_MISSING_OK = 2
1408
+ };
1409
+
1405
1410
/* Get crc32 of file */
1406
1411
pg_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 )
1408
1414
{
1409
1415
if (fio_is_remote (location ))
1410
1416
{
@@ -1417,7 +1423,9 @@ fio_get_crc32(fio_location location, const char *file_path, bool decompress)
1417
1423
hdr .arg = 0 ;
1418
1424
1419
1425
if (decompress )
1420
- hdr .arg = 1 ;
1426
+ hdr .arg = GET_CRC32_DECOMPRESS ;
1427
+ if (missing_ok )
1428
+ hdr .arg |= GET_CRC32_MISSING_OK ;
1421
1429
1422
1430
IO_CHECK (fio_write_all (fio_stdout , & hdr , sizeof (hdr )), sizeof (hdr ));
1423
1431
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)
1428
1436
else
1429
1437
{
1430
1438
if (decompress )
1431
- return pgFileGetCRCgz (file_path , true, true );
1439
+ return pgFileGetCRCgz (file_path , true, missing_ok );
1432
1440
else
1433
- return pgFileGetCRC (file_path , true, true );
1441
+ return pgFileGetCRC (file_path , true, missing_ok );
1434
1442
}
1435
1443
}
1436
1444
@@ -3365,10 +3373,10 @@ fio_communicate(int in, int out)
3365
3373
break ;
3366
3374
case FIO_GET_CRC32 :
3367
3375
/* 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 );
3370
3378
else
3371
- crc = pgFileGetCRC (buf , true, true );
3379
+ crc = pgFileGetCRC (buf , true, ( hdr . arg & GET_CRC32_MISSING_OK ) != 0 );
3372
3380
IO_CHECK (fio_write_all (out , & crc , sizeof (crc )), sizeof (crc ));
3373
3381
break ;
3374
3382
case FIO_GET_CHECKSUM_MAP :
@@ -3606,9 +3614,9 @@ pioLocalDrive_pioGetCRC32(VSelf, path_t path, bool compressed, err_i *err)
3606
3614
elog (VERBOSE , "Local Drive calculate crc32 for '%s', compressed=%d" ,
3607
3615
path , compressed );
3608
3616
if (compressed )
3609
- return pgFileGetCRCgz (path , true, true );
3617
+ return pgFileGetCRCgz (path , true, false );
3610
3618
else
3611
- return pgFileGetCRC (path , true, true );
3619
+ return pgFileGetCRC (path , true, false );
3612
3620
}
3613
3621
3614
3622
static bool
@@ -3867,7 +3875,7 @@ pioRemoteDrive_pioGetCRC32(VSelf, path_t path, bool compressed, err_i *err)
3867
3875
hdr .arg = 0 ;
3868
3876
3869
3877
if (compressed )
3870
- hdr .arg = 1 ;
3878
+ hdr .arg = GET_CRC32_DECOMPRESS ;
3871
3879
elog (VERBOSE , "Remote Drive calculate crc32 for '%s', hdr.arg=%d" ,
3872
3880
path , compressed );
3873
3881
0 commit comments