@@ -64,11 +64,6 @@ const char *PROGRAM_EMAIL = "https://github.com/postgrespro/pg_probackup/issues
6464/* directory options */
6565/* TODO make it local variable, pass as an argument to all commands that need it. */
6666static char * backup_path = NULL ;
67- /*
68- * path or to the data files in the backup catalog
69- * $BACKUP_PATH/backups/instance_name
70- */
71- static char backup_instance_path [MAXPGPATH ];
7267
7368static CatalogState * catalogState = NULL ;
7469/* ================ catalogState (END) =========== */
@@ -498,14 +493,6 @@ main(int argc, char *argv[])
498493 */
499494 if ((backup_path != NULL ) && instance_name )
500495 {
501- /*
502- * Fill global variables used to generate pathes inside the instance's
503- * backup catalog.
504- * TODO replace global variables with InstanceConfig structure fields
505- */
506- sprintf (backup_instance_path , "%s/%s/%s" ,
507- backup_path , BACKUPS_DIR , instance_name );
508-
509496 /*
510497 * Fill InstanceConfig structure fields used to generate pathes inside
511498 * the instance's backup catalog.
@@ -530,10 +517,11 @@ main(int argc, char *argv[])
530517 {
531518 struct stat st ;
532519
533- if (fio_stat (backup_instance_path , & st , true, FIO_BACKUP_HOST ) != 0 )
520+ if (fio_stat (instanceState -> instance_backup_subdir_path ,
521+ & st , true, FIO_BACKUP_HOST ) != 0 )
534522 {
535523 elog (WARNING , "Failed to access directory \"%s\": %s" ,
536- backup_instance_path , strerror (errno ));
524+ instanceState -> instance_backup_subdir_path , strerror (errno ));
537525
538526 // TODO: redundant message, should we get rid of it?
539527 elog (ERROR , "Instance '%s' does not exist in this backup catalog" ,
@@ -555,21 +543,17 @@ main(int argc, char *argv[])
555543 */
556544 if (instance_name )
557545 {
558- char path [MAXPGPATH ];
559546 /* Read environment variables */
560547 config_get_opt_env (instance_options );
561548
562549 /* Read options from configuration file */
563550 if (backup_subcmd != ADD_INSTANCE_CMD &&
564551 backup_subcmd != ARCHIVE_GET_CMD )
565552 {
566- join_path_components (path , backup_instance_path ,
567- BACKUP_CATALOG_CONF_FILE );
568-
569553 if (backup_subcmd == CHECKDB_CMD )
570- config_read_opt (path , instance_options , ERROR , true, true);
554+ config_read_opt (instanceState -> instance_config_path , instance_options , ERROR , true, true);
571555 else
572- config_read_opt (path , instance_options , ERROR , true, false);
556+ config_read_opt (instanceState -> instance_config_path , instance_options , ERROR , true, false);
573557
574558 /*
575559 * We can determine our location only after reading the configuration file,
0 commit comments