mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-01-24 11:46:31 +02:00
[Issue #113] bugfix: use rel_path attribute insead of path for sorting purposes and bsearch
This commit is contained in:
parent
dd124b34d9
commit
9c4cdef76a
12
src/dir.c
12
src/dir.c
@ -187,7 +187,7 @@ pgFile *
|
|||||||
pgFileInit(const char *path, const char *rel_path)
|
pgFileInit(const char *path, const char *rel_path)
|
||||||
{
|
{
|
||||||
pgFile *file;
|
pgFile *file;
|
||||||
char *file_name;
|
char *file_name = NULL;
|
||||||
|
|
||||||
file = (pgFile *) pgut_malloc(sizeof(pgFile));
|
file = (pgFile *) pgut_malloc(sizeof(pgFile));
|
||||||
MemSet(file, 0, sizeof(pgFile));
|
MemSet(file, 0, sizeof(pgFile));
|
||||||
@ -414,6 +414,16 @@ pgFileComparePathWithExternalDesc(const void *f1, const void *f2)
|
|||||||
return -pgFileComparePathWithExternal(f1, f2);
|
return -pgFileComparePathWithExternal(f1, f2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Compare two pgFile with their rel_path and external_dir_num
|
||||||
|
* in descending order of ASCII code.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
pgFileCompareRelPathWithExternalDesc(const void *f1, const void *f2)
|
||||||
|
{
|
||||||
|
return -pgFileCompareRelPathWithExternal(f1, f2);
|
||||||
|
}
|
||||||
|
|
||||||
/* Compare two pgFile with their linked directory path. */
|
/* Compare two pgFile with their linked directory path. */
|
||||||
int
|
int
|
||||||
pgFileCompareLinked(const void *f1, const void *f2)
|
pgFileCompareLinked(const void *f1, const void *f2)
|
||||||
|
@ -236,7 +236,7 @@ merge_backups(pgBackup *to_backup, pgBackup *from_backup)
|
|||||||
DATABASE_FILE_LIST);
|
DATABASE_FILE_LIST);
|
||||||
to_files = dir_read_file_list(NULL, NULL, control_file, FIO_BACKUP_HOST);
|
to_files = dir_read_file_list(NULL, NULL, control_file, FIO_BACKUP_HOST);
|
||||||
/* To delete from leaf, sort in reversed order */
|
/* To delete from leaf, sort in reversed order */
|
||||||
parray_qsort(to_files, pgFileComparePathWithExternalDesc);
|
parray_qsort(to_files, pgFileCompareRelPathWithExternalDesc);
|
||||||
/*
|
/*
|
||||||
* Get list of files which need to be moved.
|
* Get list of files which need to be moved.
|
||||||
*/
|
*/
|
||||||
@ -385,7 +385,7 @@ delete_source_backup:
|
|||||||
/*
|
/*
|
||||||
* Delete files which are not in from_backup file list.
|
* Delete files which are not in from_backup file list.
|
||||||
*/
|
*/
|
||||||
parray_qsort(files, pgFileComparePathWithExternalDesc);
|
parray_qsort(files, pgFileCompareRelPathWithExternalDesc);
|
||||||
for (i = 0; i < parray_num(to_files); i++)
|
for (i = 0; i < parray_num(to_files); i++)
|
||||||
{
|
{
|
||||||
pgFile *file = (pgFile *) parray_get(to_files, i);
|
pgFile *file = (pgFile *) parray_get(to_files, i);
|
||||||
@ -398,7 +398,7 @@ delete_source_backup:
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parray_bsearch(files, file, pgFileComparePathWithExternalDesc) == NULL)
|
if (parray_bsearch(files, file, pgFileCompareRelPathWithExternalDesc) == NULL)
|
||||||
{
|
{
|
||||||
char to_file_path[MAXPGPATH];
|
char to_file_path[MAXPGPATH];
|
||||||
char *prev_path;
|
char *prev_path;
|
||||||
@ -488,7 +488,7 @@ merge_files(void *arg)
|
|||||||
i + 1, num_files, file->path);
|
i + 1, num_files, file->path);
|
||||||
|
|
||||||
res_file = parray_bsearch(argument->to_files, file,
|
res_file = parray_bsearch(argument->to_files, file,
|
||||||
pgFileComparePathWithExternalDesc);
|
pgFileCompareRelPathWithExternalDesc);
|
||||||
to_file = (res_file) ? *res_file : NULL;
|
to_file = (res_file) ? *res_file : NULL;
|
||||||
|
|
||||||
join_path_components(to_file_path, argument->to_root, file->path);
|
join_path_components(to_file_path, argument->to_root, file->path);
|
||||||
|
@ -668,6 +668,7 @@ extern int pgFileCompareName(const void *f1, const void *f2);
|
|||||||
extern int pgFileComparePath(const void *f1, const void *f2);
|
extern int pgFileComparePath(const void *f1, const void *f2);
|
||||||
extern int pgFileComparePathWithExternal(const void *f1, const void *f2);
|
extern int pgFileComparePathWithExternal(const void *f1, const void *f2);
|
||||||
extern int pgFileCompareRelPathWithExternal(const void *f1, const void *f2);
|
extern int pgFileCompareRelPathWithExternal(const void *f1, const void *f2);
|
||||||
|
extern int pgFileCompareRelPathWithExternalDesc(const void *f1, const void *f2);
|
||||||
extern int pgFileComparePathDesc(const void *f1, const void *f2);
|
extern int pgFileComparePathDesc(const void *f1, const void *f2);
|
||||||
extern int pgFileComparePathWithExternalDesc(const void *f1, const void *f2);
|
extern int pgFileComparePathWithExternalDesc(const void *f1, const void *f2);
|
||||||
extern int pgFileCompareLinked(const void *f1, const void *f2);
|
extern int pgFileCompareLinked(const void *f1, const void *f2);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user