Skip to content

Commit 3c72aa5

Browse files
authored
Fix a bug where 'None' got into the path prefix we actually list with (#770)
1 parent 12de973 commit 3c72aa5

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

medusa/storage/__init__.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -487,12 +487,16 @@ def get_keyspace_and_table(manifest_object: ManifestObject) -> t.Tuple[str, str,
487487
keyspace, table = Storage.sanitize_keyspace_and_table_name(p)
488488
return keyspace, table, manifest_object
489489

490-
def list_files_per_table(self) -> t.Dict[str, t.Dict[str, t.Set[ManifestObject]]]:
491-
if self.config.prefix != '':
492-
prefix = f"{self.config.prefix}/"
490+
@staticmethod
491+
def _get_table_prefix(config_prefix, fqdn):
492+
if config_prefix is not None and config_prefix != '':
493+
prefix = f"{config_prefix}/"
493494
else:
494495
prefix = ""
495-
fdns_data_prefix = f"{prefix}{self.config.fqdn}/data/"
496+
return f"{prefix}{fqdn}/data/"
497+
498+
def list_files_per_table(self) -> t.Dict[str, t.Dict[str, t.Set[ManifestObject]]]:
499+
fdns_data_prefix = self._get_table_prefix(self.config.prefix, self.config.fqdn)
496500
all_blobs: t.List[AbstractBlob] = self.storage_driver.list_blobs(prefix=fdns_data_prefix)
497501
all_files = [ManifestObject(blob.name, blob.size, blob.hash) for blob in all_blobs]
498502
keyspace_table_mo_tuples = map(Storage.get_keyspace_and_table, all_files)

tests/storage_test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,11 @@ def test_saniitize_keyspace_and_table_name(self):
449449
self.storage.sanitize_keyspace_and_table_name(p)
450450
)
451451

452+
def test_get_table_prefix(self):
453+
self.assertEqual('localhost/data/', self.storage._get_table_prefix(None, 'localhost'))
454+
self.assertEqual('localhost/data/', self.storage._get_table_prefix('', 'localhost'))
455+
self.assertEqual('prefix/localhost/data/', self.storage._get_table_prefix('prefix', 'localhost'))
456+
452457

453458
def make_node_backup(storage, name, backup_date, differential=False, fqdn="localhost"):
454459
if differential is True:

0 commit comments

Comments
 (0)