Skip to content
Snippets Groups Projects
Unverified Commit a0e99054 authored by Jean-Paul Calderone's avatar Jean-Paul Calderone
Browse files

Avoid repeating storage indexes in the node hierarchy

It's not impossible or even disallowed.  However, if a storage index is
repeated it sure as heck better have the same object associated with it -
which this strategy does not ensure.
parent 3853a3a3
No related branches found
No related tags found
1 merge request!80Record pass spending during lease maintenance
...@@ -657,7 +657,18 @@ def node_hierarchies(): ...@@ -657,7 +657,18 @@ def node_hierarchies():
Build hierarchies of ``IDirectoryNode`` and other ``IFilesystemNode`` Build hierarchies of ``IDirectoryNode`` and other ``IFilesystemNode``
(incomplete) providers. (incomplete) providers.
""" """
def storage_indexes_are_distinct(nodes):
seen = set()
for n in nodes.flatten():
si = n.get_storage_index()
if si in seen:
return False
seen.add(si)
return True
return recursive( return recursive(
leaf_nodes(), leaf_nodes(),
directory_nodes, directory_nodes,
).filter(
storage_indexes_are_distinct,
) )
...@@ -552,7 +552,7 @@ class MaintainLeasesFromRootTests(TestCase): ...@@ -552,7 +552,7 @@ class MaintainLeasesFromRootTests(TestCase):
for node in root_node.flatten(): for node in root_node.flatten():
for storage_server in storage_broker.get_connected_servers(): for storage_server in storage_broker.get_connected_servers():
try: try:
stat = storage_server.buckets[node._storage_index] stat = storage_server.buckets[node.get_storage_index()]
except KeyError: except KeyError:
continue continue
else: else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment