1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2024-11-28 09:33:54 +02:00

restore code cleanup

This commit is contained in:
Anastasia 2017-05-03 15:55:11 +03:00
parent 2b8da45f09
commit 7777afceb4
3 changed files with 12 additions and 16 deletions

16
data.c
View File

@ -406,7 +406,7 @@ restore_file_partly(const char *from_root,const char *to_root, pgFile *file)
fclose(out);
}
static void
void
restore_compressed_file(const char *from_root,
const char *to_root,
pgFile *file)
@ -436,20 +436,6 @@ restore_data_file(const char *from_root,
BackupPageHeader header;
BlockNumber blknum;
if (!file->is_datafile)
{
/*
* If the file is not a datafile and not compressed file,
* just copy it.
*/
if (file->generation == -1)
copy_file(from_root, to_root, file);
else
restore_compressed_file(from_root, to_root, file);
return;
}
/* open backup mode file for read */
in = fopen(file->path, "r");
if (in == NULL)

View File

@ -344,6 +344,8 @@ extern bool backup_data_file(const char *from_root, const char *to_root,
pgFile *file, XLogRecPtr prev_backup_start_lsn);
extern void restore_data_file(const char *from_root, const char *to_root,
pgFile *file, pgBackup *backup);
extern void restore_compressed_file(const char *from_root,
const char *to_root, pgFile *file);
extern bool is_compressed_data_file(pgFile *file);
extern bool backup_compressed_file_partially(pgFile *file,
void *arg,

View File

@ -666,7 +666,15 @@ restore_files(void *arg)
}
/* restore file */
restore_data_file(from_root, pgdata, file, arguments->backup);
if (file->is_datafile)
{
if (is_compressed_data_file(file))
restore_compressed_file(from_root, pgdata, file);
else
restore_data_file(from_root, pgdata, file, arguments->backup);
}
else
copy_file(from_root, pgdata, file);
/* print size of restored file */
elog(LOG, "restored %lu\n", (unsigned long) file->write_size);