mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-02-03 14:01:57 +02:00
Remove flag is_extra, use extra_dir_num instead
This commit is contained in:
parent
863486be7e
commit
4bb9b775bf
@ -702,7 +702,7 @@ do_backup_instance(void)
|
|||||||
char *dir_name;
|
char *dir_name;
|
||||||
|
|
||||||
if (!is_remote_backup)
|
if (!is_remote_backup)
|
||||||
if (file->is_extra)
|
if (file->extra_dir_num)
|
||||||
dir_name = GetRelativePath(file->path, file->extradir);
|
dir_name = GetRelativePath(file->path, file->extradir);
|
||||||
else
|
else
|
||||||
dir_name = GetRelativePath(file->path, pgdata);
|
dir_name = GetRelativePath(file->path, pgdata);
|
||||||
|
15
src/dir.c
15
src/dir.c
@ -175,7 +175,6 @@ pgFileNew(const char *path, bool omit_symlink, int extra_dir_num)
|
|||||||
file = pgFileInit(path);
|
file = pgFileInit(path);
|
||||||
file->size = st.st_size;
|
file->size = st.st_size;
|
||||||
file->mode = st.st_mode;
|
file->mode = st.st_mode;
|
||||||
file->is_extra = extra_dir_num > 0;
|
|
||||||
file->extra_dir_num = extra_dir_num;
|
file->extra_dir_num = extra_dir_num;
|
||||||
file->extradir = NULL;
|
file->extradir = NULL;
|
||||||
|
|
||||||
@ -228,6 +227,7 @@ pgFileInit(const char *path)
|
|||||||
/* Number of blocks readed during backup */
|
/* Number of blocks readed during backup */
|
||||||
file->n_blocks = BLOCKNUM_INVALID;
|
file->n_blocks = BLOCKNUM_INVALID;
|
||||||
file->compress_alg = NOT_DEFINED_COMPRESS;
|
file->compress_alg = NOT_DEFINED_COMPRESS;
|
||||||
|
file->extra_dir_num = 0;
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1198,18 +1198,16 @@ print_file_list(FILE *out, const parray *files, const char *root)
|
|||||||
/* omit root directory portion */
|
/* omit root directory portion */
|
||||||
if (root && strstr(path, root) == path)
|
if (root && strstr(path, root) == path)
|
||||||
path = GetRelativePath(path, root);
|
path = GetRelativePath(path, root);
|
||||||
else if(file->is_extra)
|
else if(file->extra_dir_num)
|
||||||
path = GetRelativePath(path, file->extradir);
|
path = GetRelativePath(path, file->extradir);
|
||||||
|
|
||||||
fprintf(out, "{\"path\":\"%s\", \"size\":\"" INT64_FORMAT "\", "
|
fprintf(out, "{\"path\":\"%s\", \"size\":\"" INT64_FORMAT "\", "
|
||||||
"\"mode\":\"%u\", \"is_datafile\":\"%u\", "
|
"\"mode\":\"%u\", \"is_datafile\":\"%u\", "
|
||||||
"\"is_cfs\":\"%u\", \"crc\":\"%u\", "
|
"\"is_cfs\":\"%u\", \"crc\":\"%u\", "
|
||||||
"\"compress_alg\":\"%s\", \"is_extra\":\"%u\""
|
"\"compress_alg\":\"%s\", \"extra_dir_num\":\"%u\"",
|
||||||
", \"extra_dir_num\":\"%u\"",
|
|
||||||
path, file->write_size, file->mode,
|
path, file->write_size, file->mode,
|
||||||
file->is_datafile ? 1 : 0, file->is_cfs ? 1 : 0, file->crc,
|
file->is_datafile ? 1 : 0, file->is_cfs ? 1 : 0, file->crc,
|
||||||
deparse_compress_alg(file->compress_alg),
|
deparse_compress_alg(file->compress_alg), file->extra_dir_num);
|
||||||
file->is_extra ? 1 : 0, file->extra_dir_num);
|
|
||||||
|
|
||||||
if (file->extradir)
|
if (file->extradir)
|
||||||
fprintf(out, ",\"extradir\":\"%s\"", file->extradir);
|
fprintf(out, ",\"extradir\":\"%s\"", file->extradir);
|
||||||
@ -1402,7 +1400,6 @@ dir_read_file_list(const char *root, const char *extra_path, const char *file_tx
|
|||||||
mode, /* bit length of mode_t depends on platforms */
|
mode, /* bit length of mode_t depends on platforms */
|
||||||
is_datafile,
|
is_datafile,
|
||||||
is_cfs,
|
is_cfs,
|
||||||
is_extra,
|
|
||||||
extra_dir_num,
|
extra_dir_num,
|
||||||
crc,
|
crc,
|
||||||
segno,
|
segno,
|
||||||
@ -1416,7 +1413,6 @@ dir_read_file_list(const char *root, const char *extra_path, const char *file_tx
|
|||||||
get_control_value(buf, "is_cfs", NULL, &is_cfs, false);
|
get_control_value(buf, "is_cfs", NULL, &is_cfs, false);
|
||||||
get_control_value(buf, "crc", NULL, &crc, true);
|
get_control_value(buf, "crc", NULL, &crc, true);
|
||||||
get_control_value(buf, "compress_alg", compress_alg_string, NULL, false);
|
get_control_value(buf, "compress_alg", compress_alg_string, NULL, false);
|
||||||
get_control_value(buf, "is_extra", NULL, &is_extra, false);
|
|
||||||
get_control_value(buf, "extra_dir_num", NULL, &extra_dir_num, false);
|
get_control_value(buf, "extra_dir_num", NULL, &extra_dir_num, false);
|
||||||
|
|
||||||
if (root)
|
if (root)
|
||||||
@ -1433,8 +1429,7 @@ dir_read_file_list(const char *root, const char *extra_path, const char *file_tx
|
|||||||
|
|
||||||
file = pgFileInit(filepath);
|
file = pgFileInit(filepath);
|
||||||
|
|
||||||
file->is_extra = is_extra ? true : false;
|
if (extra_dir_num)
|
||||||
if (is_extra)
|
|
||||||
{
|
{
|
||||||
get_control_value(buf, "extradir", extradir_str, NULL, true);
|
get_control_value(buf, "extradir", extradir_str, NULL, true);
|
||||||
file->extradir = pgut_strdup(extradir_str);
|
file->extradir = pgut_strdup(extradir_str);
|
||||||
|
@ -116,7 +116,6 @@ typedef struct pgFile
|
|||||||
int n_blocks; /* size of the file in blocks, readed during DELTA backup */
|
int n_blocks; /* size of the file in blocks, readed during DELTA backup */
|
||||||
bool is_cfs; /* Flag to distinguish files compressed by CFS*/
|
bool is_cfs; /* Flag to distinguish files compressed by CFS*/
|
||||||
bool is_database;
|
bool is_database;
|
||||||
bool is_extra;
|
|
||||||
bool extra_dir_num; /* Number of extra directory. 0 if not extra */
|
bool extra_dir_num; /* Number of extra directory. 0 if not extra */
|
||||||
char *extradir; /* File from extra directory */
|
char *extradir; /* File from extra directory */
|
||||||
bool exists_in_prev; /* Mark files, both data and regular, that exists in previous backup */
|
bool exists_in_prev; /* Mark files, both data and regular, that exists in previous backup */
|
||||||
|
@ -478,17 +478,18 @@ restore_backup(pgBackup *backup)
|
|||||||
char dirpath[MAXPGPATH];
|
char dirpath[MAXPGPATH];
|
||||||
char *dir_name;
|
char *dir_name;
|
||||||
|
|
||||||
if (file->is_extra)
|
if (file->extra_dir_num)
|
||||||
dir_name = GetRelativePath(file->path, extra_path);
|
{
|
||||||
else
|
|
||||||
dir_name = GetRelativePath(file->path, database_path);
|
|
||||||
|
|
||||||
elog(VERBOSE, "Create directory \"%s\" NAME %s", dir_name, file->name);
|
|
||||||
|
|
||||||
if (file->is_extra)
|
|
||||||
join_path_components(dirpath, file->extradir, dir_name);
|
join_path_components(dirpath, file->extradir, dir_name);
|
||||||
|
elog(VERBOSE, "Create directory \"%s\" NAME %s", dir_name, file->name);
|
||||||
|
dir_name = GetRelativePath(file->path, extra_path);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
dir_name = GetRelativePath(file->path, database_path);
|
||||||
|
elog(VERBOSE, "Create directory \"%s\" NAME %s", dir_name, file->name);
|
||||||
join_path_components(dirpath, pgdata, dir_name);
|
join_path_components(dirpath, pgdata, dir_name);
|
||||||
|
}
|
||||||
dir_create_dir(dirpath, DIR_PERMISSION);
|
dir_create_dir(dirpath, DIR_PERMISSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -659,7 +660,7 @@ restore_files(void *arg)
|
|||||||
false,
|
false,
|
||||||
parse_program_version(arguments->backup->program_version));
|
parse_program_version(arguments->backup->program_version));
|
||||||
}
|
}
|
||||||
else if (file->is_extra)
|
else if (file->extra_dir_num)
|
||||||
copy_file(from_root, file->extradir, file);
|
copy_file(from_root, file->extradir, file);
|
||||||
else
|
else
|
||||||
copy_file(from_root, pgdata, file);
|
copy_file(from_root, pgdata, file);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user