Skip to content

Commit 32d283f

Browse files
committed
Check for existance of an external directory
1 parent d489cc7 commit 32d283f

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

src/backup.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,8 @@ do_backup_instance(void)
888888
/* Scan backup PG_XLOG_DIR */
889889
xlog_files_list = parray_new();
890890
join_path_components(pg_xlog_path, database_path, PG_XLOG_DIR);
891-
dir_list_file(xlog_files_list, pg_xlog_path, false, true, false, 0, FIO_BACKUP_HOST);
891+
dir_list_file(xlog_files_list, pg_xlog_path, false, true, false, 0,
892+
FIO_BACKUP_HOST);
892893

893894
for (i = 0; i < parray_num(xlog_files_list); i++)
894895
{

src/dir.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,14 @@ dir_create_dir(const char *dir, mode_t mode)
163163
}
164164

165165
pgFile *
166-
pgFileNew(const char *path, bool omit_symlink, int external_dir_num, fio_location location)
166+
pgFileNew(const char *path, bool omit_symlink, int external_dir_num,
167+
fio_location location)
167168
{
168169
struct stat st;
169170
pgFile *file;
170171

171-
/* stat the file */
172-
if (fio_stat(path, &st, omit_symlink, location) < 0)
172+
/* stat the file */
173+
if (fio_stat(path, &st, omit_symlink, location) < 0)
173174
{
174175
/* file not found is not an error case */
175176
if (errno == ENOENT)
@@ -475,11 +476,17 @@ dir_list_file(parray *files, const char *root, bool exclude, bool omit_symlink,
475476

476477
file = pgFileNew(root, omit_symlink, external_dir_num, location);
477478
if (file == NULL)
478-
return;
479+
{
480+
/* For external directory this is not ok */
481+
if (external_dir_num > 0)
482+
elog(ERROR, "Exteral directory is not found: %s", root);
483+
else
484+
return;
485+
}
479486

480487
if (!S_ISDIR(file->mode))
481488
{
482-
if (external_dir_num)
489+
if (external_dir_num > 0)
483490
elog(ERROR, " --external-dirs option \"%s\": directory or symbolic link expected",
484491
file->path);
485492
else

src/restore.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,8 @@ remove_deleted_files(pgBackup *backup)
640640

641641
/* Get list of files actually existing in target database */
642642
files_restored = parray_new();
643-
dir_list_file(files_restored, instance_config.pgdata, true, true, false, 0, FIO_BACKUP_HOST);
643+
dir_list_file(files_restored, instance_config.pgdata, true, true, false, 0,
644+
FIO_BACKUP_HOST);
644645
/* To delete from leaf, sort in reversed order */
645646
parray_qsort(files_restored, pgFileComparePathDesc);
646647

0 commit comments

Comments
 (0)