@@ -90,7 +90,7 @@ static char *pgdata_exclude_files_non_exclusive[] =
90
90
91
91
static int BlackListCompare (const void * str1 , const void * str2 );
92
92
93
- static bool dir_check_file (const char * root , pgFile * file , bool exclude );
93
+ static bool dir_check_file (const char * root , pgFile * file );
94
94
static void dir_list_file_internal (parray * files , const char * root ,
95
95
pgFile * parent , bool exclude ,
96
96
bool omit_symlink , parray * black_list );
@@ -401,67 +401,64 @@ dir_list_file(parray *files, const char *root, bool exclude, bool omit_symlink,
401
401
* - datafiles
402
402
*/
403
403
static bool
404
- dir_check_file (const char * root , pgFile * file , bool exclude )
404
+ dir_check_file (const char * root , pgFile * file )
405
405
{
406
406
const char * rel_path ;
407
407
int i ;
408
408
int sscanf_res ;
409
409
410
- if (exclude )
410
+ /* Check if we need to exclude file by name */
411
+ if (S_ISREG (file -> mode ))
411
412
{
412
- /* Check if we need to exclude file by name */
413
- if (S_ISREG (file -> mode ))
413
+ if (!exclusive_backup )
414
414
{
415
- if (!exclusive_backup )
416
- {
417
- for (i = 0 ; pgdata_exclude_files_non_exclusive [i ]; i ++ )
418
- if (strcmp (file -> name ,
419
- pgdata_exclude_files_non_exclusive [i ]) == 0 )
420
- {
421
- /* Skip */
422
- elog (VERBOSE , "Excluding file: %s" , file -> name );
423
- return false;
424
- }
425
- }
426
-
427
- for (i = 0 ; pgdata_exclude_files [i ]; i ++ )
428
- if (strcmp (file -> name , pgdata_exclude_files [i ]) == 0 )
415
+ for (i = 0 ; pgdata_exclude_files_non_exclusive [i ]; i ++ )
416
+ if (strcmp (file -> name ,
417
+ pgdata_exclude_files_non_exclusive [i ]) == 0 )
429
418
{
430
419
/* Skip */
431
420
elog (VERBOSE , "Excluding file: %s" , file -> name );
432
421
return false;
433
422
}
434
423
}
424
+
425
+ for (i = 0 ; pgdata_exclude_files [i ]; i ++ )
426
+ if (strcmp (file -> name , pgdata_exclude_files [i ]) == 0 )
427
+ {
428
+ /* Skip */
429
+ elog (VERBOSE , "Excluding file: %s" , file -> name );
430
+ return false;
431
+ }
432
+ }
433
+ /*
434
+ * If the directory name is in the exclude list, do not list the
435
+ * contents.
436
+ */
437
+ else if (S_ISDIR (file -> mode ))
438
+ {
435
439
/*
436
- * If the directory name is in the exclude list, do not list the
437
- * contents.
440
+ * If the item in the exclude list starts with '/', compare to
441
+ * the absolute path of the directory. Otherwise compare to the
442
+ * directory name portion.
438
443
*/
439
- else if ( S_ISDIR ( file -> mode ) )
444
+ for ( i = 0 ; pgdata_exclude_dir [ i ]; i ++ )
440
445
{
441
- /*
442
- * If the item in the exclude list starts with '/', compare to
443
- * the absolute path of the directory. Otherwise compare to the
444
- * directory name portion.
445
- */
446
- for (i = 0 ; pgdata_exclude_dir [i ]; i ++ )
446
+ /* Full-path exclude*/
447
+ if (pgdata_exclude_dir [i ][0 ] == '/' )
447
448
{
448
- /* Full-path exclude*/
449
- if (pgdata_exclude_dir [i ][0 ] == '/' )
450
- {
451
- if (strcmp (file -> path , pgdata_exclude_dir [i ]) == 0 )
452
- {
453
- elog (VERBOSE , "Excluding directory content: %s" ,
454
- file -> name );
455
- return false;
456
- }
457
- }
458
- else if (strcmp (file -> name , pgdata_exclude_dir [i ]) == 0 )
449
+ if (strcmp (file -> path , pgdata_exclude_dir [i ]) == 0 )
459
450
{
460
451
elog (VERBOSE , "Excluding directory content: %s" ,
461
452
file -> name );
462
453
return false;
463
454
}
464
455
}
456
+ else if (strcmp (file -> name , pgdata_exclude_dir [i ]) == 0 )
457
+ {
458
+ elog (VERBOSE , "Excluding directory content: %s" ,
459
+ file -> name );
460
+ return false;
461
+ }
465
462
}
466
463
}
467
464
@@ -500,27 +497,26 @@ dir_check_file(const char *root, pgFile *file, bool exclude)
500
497
{
501
498
file -> tblspcOid = DEFAULTTABLESPACE_OID ;
502
499
503
- sscanf_res = sscanf (rel_path , "base/%u/" , & (file -> dbOid ));
500
+ sscanf (rel_path , "base/%u/" , & (file -> dbOid ));
504
501
505
502
if (S_ISDIR (file -> mode ) && strcmp (file -> name , "base" ) != 0 )
506
- {
507
503
file -> is_database = true;
508
- sscanf (rel_path , "base/%u/" , & (file -> dbOid ));
509
- }
510
504
}
511
505
else if (path_is_prefix_of_path (PG_TBLSPC_DIR , rel_path ))
512
506
{
513
507
char tmp_rel_path [MAXPGPATH ];
514
508
515
- sscanf_res = sscanf (rel_path , PG_TBLSPC_DIR "/%u/%s /%u/" ,
509
+ sscanf_res = sscanf (rel_path , PG_TBLSPC_DIR "/%u/%[^/] /%u/" ,
516
510
& (file -> tblspcOid ), tmp_rel_path ,
517
511
& (file -> dbOid ));
518
512
519
513
if (sscanf_res == 3 && S_ISDIR (file -> mode ) &&
520
514
strcmp (tmp_rel_path , TABLESPACE_VERSION_DIRECTORY ) == 0 )
521
515
file -> is_database = true;
522
516
}
523
- else if (S_ISREG (file -> mode ) && strcmp (file -> name , "ptrack_init" ) == 0 )
517
+
518
+ /* Do not backup ptrack_init files */
519
+ if (S_ISREG (file -> mode ) && strcmp (file -> name , "ptrack_init" ) == 0 )
524
520
return false;
525
521
526
522
/*
@@ -642,7 +638,7 @@ dir_list_file_internal(parray *files, const char *root, pgFile *parent,
642
638
if (S_ISDIR (file -> mode ))
643
639
parray_append (files , file );
644
640
645
- if (!dir_check_file (root , file , exclude ))
641
+ if (exclude && !dir_check_file (root , file ))
646
642
{
647
643
if (S_ISREG (file -> mode ))
648
644
pgFileFree (file );
0 commit comments