Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 19c30a8

Browse files
committed
code cleanup: remove unneeded backuped variable
1 parent 52a5487 commit 19c30a8

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

src/backup.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,6 @@ do_backup_instance(PGconn *backup_conn)
429429
}
430430
else
431431
join_path_components(dirpath, database_path, dir_name);
432-
file->backuped = true;
433432
fio_mkdir(dirpath, DIR_PERMISSION, FIO_BACKUP_HOST);
434433
}
435434

@@ -443,6 +442,11 @@ do_backup_instance(PGconn *backup_conn)
443442
if (prev_backup_filelist)
444443
parray_qsort(prev_backup_filelist, pgFileComparePathWithExternal);
445444

445+
/* write initial backup_content.control file and update backup.control */
446+
write_backup_filelist(&current, backup_files_list,
447+
instance_config.pgdata, external_dirs);
448+
write_backup(&current);
449+
446450
/* init thread args with own file lists */
447451
threads = (pthread_t *) palloc(sizeof(pthread_t) * num_threads);
448452
threads_args = (backup_files_arg *) palloc(sizeof(backup_files_arg)*num_threads);
@@ -1797,7 +1801,6 @@ pg_stop_backup(pgBackup *backup, PGconn *pg_startbackup_conn)
17971801
file->crc = pgFileGetCRC(file->path, true, false,
17981802
&file->read_size, FIO_BACKUP_HOST);
17991803
file->write_size = file->read_size;
1800-
file->backuped = true;
18011804
free(file->path);
18021805
file->path = strdup(PG_BACKUP_LABEL_FILE);
18031806
parray_append(backup_files_list, file);
@@ -1846,7 +1849,6 @@ pg_stop_backup(pgBackup *backup, PGconn *pg_startbackup_conn)
18461849
file->crc = pgFileGetCRC(file->path, true, false,
18471850
&file->read_size, FIO_BACKUP_HOST);
18481851
file->write_size = file->read_size;
1849-
file->backuped = true;
18501852
}
18511853
free(file->path);
18521854
file->path = strdup(PG_TABLESPACE_MAP_FILE);
@@ -1995,7 +1997,7 @@ backup_files(void *arg)
19951997
{
19961998
prev_time = time(NULL);
19971999

1998-
write_backup_filelist(&current, arguments->files_list, instance_config.pgdata,
2000+
write_backup_filelist(&current, arguments->files_list, arguments->from_root,
19992001
arguments->external_dirs);
20002002
/* update backup control file to update size info */
20012003
write_backup(&current);
@@ -2134,7 +2136,6 @@ backup_files(void *arg)
21342136
}
21352137
}
21362138

2137-
file->backuped = true;
21382139
elog(VERBOSE, "File \"%s\". Copied "INT64_FORMAT " bytes",
21392140
file->path, file->write_size);
21402141
}

src/catalog.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -660,16 +660,11 @@ write_backup_filelist(pgBackup *backup, parray *files, const char *root,
660660

661661
i++;
662662

663-
/* if file is not backuped yet, do not add it to the list */
664-
/* TODO check that we correctly handle files which disappeared during backups */
665-
if (!file->backuped)
666-
continue;
667-
668663
if (S_ISDIR(file->mode))
669664
backup_size_on_disk += 4096;
670665

671666
/* Count the amount of the data actually copied */
672-
if (S_ISREG(file->mode))
667+
if (S_ISREG(file->mode) && file->write_size > 0)
673668
backup_size_on_disk += file->write_size;
674669

675670
if (file->external_dir_num && external_list)

src/pg_probackup.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,6 @@ typedef struct pgFile
146146
datapagemap_t pagemap; /* bitmap of pages updated since previous backup */
147147
bool pagemap_isabsent; /* Used to mark files with unknown state of pagemap,
148148
* i.e. datafiles without _ptrack */
149-
150-
/* state during bakup */
151-
bool backuped; /* is file already completely copied into destination backup? */
152149
} pgFile;
153150

154151
/* Special values of datapagemap_t bitmapsize */

0 commit comments

Comments
 (0)