Skip to content

Commit 79d26cd

Browse files
committed
[Issue #217] delete of backup with hidden files works correctly now
1 parent 205ca27 commit 79d26cd

File tree

8 files changed

+16
-16
lines changed

8 files changed

+16
-16
lines changed

src/archive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ setup_push_filelist(const char *archive_status_dir, const char *first_file,
944944

945945
/* get list of files from archive_status */
946946
status_files = parray_new();
947-
dir_list_file(status_files, archive_status_dir, false, false, false, 0, FIO_DB_HOST);
947+
dir_list_file(status_files, archive_status_dir, false, false, false, true, 0, FIO_DB_HOST);
948948
parray_qsort(status_files, pgFileComparePath);
949949

950950
for (i = 0; i < parray_num(status_files); i++)

src/backup.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ do_backup_instance(PGconn *backup_conn, PGNodeInfo *nodeInfo, bool no_sync)
333333

334334
/* list files with the logical path. omit $PGDATA */
335335
dir_list_file(backup_files_list, instance_config.pgdata,
336-
true, true, false, 0, FIO_DB_HOST);
336+
true, true, false, true, 0, FIO_DB_HOST);
337337

338338
/*
339339
* Get database_map (name to oid) for use in partial restore feature.
@@ -350,7 +350,7 @@ do_backup_instance(PGconn *backup_conn, PGNodeInfo *nodeInfo, bool no_sync)
350350
/* External dirs numeration starts with 1.
351351
* 0 value is not external dir */
352352
dir_list_file(backup_files_list, parray_get(external_dirs, i),
353-
false, true, false, i+1, FIO_DB_HOST);
353+
false, true, false, true, i+1, FIO_DB_HOST);
354354

355355
/* close ssh session in main thread */
356356
fio_disconnect();
@@ -627,7 +627,7 @@ do_backup_instance(PGconn *backup_conn, PGNodeInfo *nodeInfo, bool no_sync)
627627
/* Scan backup PG_XLOG_DIR */
628628
xlog_files_list = parray_new();
629629
join_path_components(pg_xlog_path, database_path, PG_XLOG_DIR);
630-
dir_list_file(xlog_files_list, pg_xlog_path, false, true, false, 0,
630+
dir_list_file(xlog_files_list, pg_xlog_path, false, true, false, true, 0,
631631
FIO_BACKUP_HOST);
632632

633633
/* TODO: Drop streamed WAL segments greater than stop_lsn */

src/catalog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ catalog_get_timelines(InstanceConfig *instance)
872872

873873
/* read all xlog files that belong to this archive */
874874
sprintf(arclog_path, "%s/%s/%s", backup_path, "wal", instance->name);
875-
dir_list_file(xlog_files_list, arclog_path, false, false, false, 0, FIO_BACKUP_HOST);
875+
dir_list_file(xlog_files_list, arclog_path, false, false, false, true, 0, FIO_BACKUP_HOST);
876876
parray_qsort(xlog_files_list, pgFileComparePath);
877877

878878
timelineinfos = parray_new();

src/checkdb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ do_block_validation(char *pgdata, uint32 checksum_version)
208208

209209
/* list files with the logical path. omit $PGDATA */
210210
dir_list_file(files_list, pgdata,
211-
true, true, false, 0, FIO_DB_HOST);
211+
true, true, false, true, 0, FIO_DB_HOST);
212212

213213
/*
214214
* Sort pathname ascending.

src/delete.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ delete_backup_files(pgBackup *backup)
750750

751751
/* list files to be deleted */
752752
files = parray_new();
753-
dir_list_file(files, backup->root_dir, false, true, true, 0, FIO_BACKUP_HOST);
753+
dir_list_file(files, backup->root_dir, false, true, true, false, 0, FIO_BACKUP_HOST);
754754

755755
/* delete leaf node first */
756756
parray_qsort(files, pgFileComparePathDesc);
@@ -984,7 +984,7 @@ do_delete_instance(void)
984984

985985
/* Delete all wal files. */
986986
xlog_files_list = parray_new();
987-
dir_list_file(xlog_files_list, arclog_path, false, false, false, 0, FIO_BACKUP_HOST);
987+
dir_list_file(xlog_files_list, arclog_path, false, false, false, false, 0, FIO_BACKUP_HOST);
988988

989989
for (i = 0; i < parray_num(xlog_files_list); i++)
990990
{

src/dir.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static int pgCompareString(const void *str1, const void *str2);
125125

126126
static char dir_check_file(pgFile *file);
127127
static void dir_list_file_internal(parray *files, pgFile *parent, bool exclude,
128-
bool follow_symlink,
128+
bool follow_symlink, bool skip_hidden,
129129
int external_dir_num, fio_location location);
130130
static void opt_path_map(ConfigOption *opt, const char *arg,
131131
TablespaceList *list, const char *type);
@@ -575,7 +575,7 @@ db_map_entry_free(void *entry)
575575
*/
576576
void
577577
dir_list_file(parray *files, const char *root, bool exclude, bool follow_symlink,
578-
bool add_root, int external_dir_num, fio_location location)
578+
bool add_root, bool skip_hidden, int external_dir_num, fio_location location)
579579
{
580580
pgFile *file;
581581

@@ -601,7 +601,7 @@ dir_list_file(parray *files, const char *root, bool exclude, bool follow_symlink
601601
if (add_root)
602602
parray_append(files, file);
603603

604-
dir_list_file_internal(files, file, exclude, follow_symlink,
604+
dir_list_file_internal(files, file, exclude, follow_symlink, skip_hidden,
605605
external_dir_num, location);
606606

607607
if (!add_root)
@@ -821,7 +821,7 @@ dir_check_file(pgFile *file)
821821
*/
822822
static void
823823
dir_list_file_internal(parray *files, pgFile *parent, bool exclude,
824-
bool follow_symlink,
824+
bool follow_symlink, bool skip_hidden,
825825
int external_dir_num, fio_location location)
826826
{
827827
DIR *dir;
@@ -868,7 +868,7 @@ dir_list_file_internal(parray *files, pgFile *parent, bool exclude,
868868
}
869869

870870
/* skip hidden files and directories */
871-
if (file->name[0] == '.')
871+
if (skip_hidden && file->name[0] == '.')
872872
{
873873
elog(WARNING, "Skip hidden file: '%s'", file->path);
874874
pgFileFree(file);
@@ -911,7 +911,7 @@ dir_list_file_internal(parray *files, pgFile *parent, bool exclude,
911911
*/
912912
if (S_ISDIR(file->mode))
913913
dir_list_file_internal(files, file, exclude, follow_symlink,
914-
external_dir_num, location);
914+
skip_hidden, external_dir_num, location);
915915
}
916916

917917
if (errno && errno != ENOENT)

src/merge.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,7 @@ remove_dir_with_files(const char *path)
10551055
int i;
10561056
char full_path[MAXPGPATH];
10571057

1058-
dir_list_file(files, path, true, true, true, 0, FIO_LOCAL_HOST);
1058+
dir_list_file(files, path, true, true, true, false, 0, FIO_LOCAL_HOST);
10591059
parray_qsort(files, pgFileComparePathDesc);
10601060
for (i = 0; i < parray_num(files); i++)
10611061
{

src/pg_probackup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ extern const char* deparse_compress_alg(int alg);
845845

846846
/* in dir.c */
847847
extern void dir_list_file(parray *files, const char *root, bool exclude,
848-
bool follow_symlink, bool add_root,
848+
bool follow_symlink, bool add_root, bool skip_hidden,
849849
int external_dir_num, fio_location location);
850850

851851
extern void create_data_directories(parray *dest_files,

0 commit comments

Comments
 (0)