@@ -416,7 +416,7 @@ restore_directories(const char *pg_data_dir, const char *backup_dir)
416
416
link_name [len ]= '\0' ;
417
417
}
418
418
else
419
- strcpy ( link_name , link_ptr ) ;
419
+ goto create_directory ;
420
420
421
421
tmp_ptr = dir -> path ;
422
422
dir -> path = link_name ;
@@ -442,7 +442,13 @@ restore_directories(const char *pg_data_dir, const char *backup_dir)
442
442
* create it second time.
443
443
*/
444
444
if (strcmp (dir_created ,linked_path )== 0 )
445
- continue ;
445
+ {
446
+ /* Create rest of directories */
447
+ if (link_sep && (link_sep + 1 ))
448
+ gotocreate_directory ;
449
+ else
450
+ continue ;
451
+ }
446
452
else
447
453
elog (ERROR ,"tablespace directory \"%s\" of page backup does not "
448
454
"match with previous created tablespace directory \"%s\" of symlink \"%s\"" ,
@@ -467,12 +473,6 @@ restore_directories(const char *pg_data_dir, const char *backup_dir)
467
473
468
474
/* Firstly, create linked directory */
469
475
dir_create_dir (linked_path ,DIR_PERMISSION );
470
- /* Create rest of directories */
471
- if (link_sep && (link_sep + 1 ))
472
- {
473
- join_path_components (to_path ,linked_path ,link_sep + 1 );
474
- dir_create_dir (to_path ,DIR_PERMISSION );
475
- }
476
476
477
477
join_path_components (to_path ,pg_data_dir ,PG_TBLSPC_DIR );
478
478
/* Create pg_tblspc directory just in case */
@@ -487,10 +487,15 @@ restore_directories(const char *pg_data_dir, const char *backup_dir)
487
487
/* Save linked directory */
488
488
set_tablespace_created (link_name ,linked_path );
489
489
490
+ /* Create rest of directories */
491
+ if (link_sep && (link_sep + 1 ))
492
+ gotocreate_directory ;
493
+
490
494
continue ;
491
495
}
492
496
}
493
497
498
+ create_directory :
494
499
elog (LOG ,"create directory \"%s\"" ,relative_ptr );
495
500
496
501
/* This is not symlink, create directory */