Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4d3dd70

Browse files
committed
Allow only an absolute backup dir prefix
1 parent 48195d1 commit 4d3dd70

File tree

1 file changed

+5
-3
lines changed
  • testgres/plugins/pg_probackup2/pg_probackup2/storage

1 file changed

+5
-3
lines changed

testgres/plugins/pg_probackup2/pg_probackup2/storage/fs_backup.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ class FSTestBackupDir(TestBackupDir):
4343
""" Backup directory. Usually created by running pg_probackup init -B <path>"""
4444

4545
def __init__(self, *, rel_path, backup):
46-
backup_prefix = os.environ.get('PG_PROBACKUP_TEST_BACKUP_DIR_PREFIX', '')
47-
if os.path.isabs(backup_prefix):
46+
backup_prefix = os.environ.get('PG_PROBACKUP_TEST_BACKUP_DIR_PREFIX')
47+
if backup_prefix:
48+
if not os.path.isabs(backup_prefix):
49+
raise Exception(f"PG_PROBACKUP_TEST_BACKUP_DIR_PREFIX must be an absolute path, current value: {backup_prefix}")
4850
self.path = os.path.join(backup_prefix, rel_path, backup)
4951
else:
50-
self.path = os.path.join(init_params.tmp_path, backup_prefix, rel_path, backup)
52+
self.path = os.path.join(init_params.tmp_path, rel_path, backup)
5153
self.pb_args = ('-B', self.path)
5254

5355
def list_instance_backups(self, instance):

0 commit comments

Comments
 (0)