mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-06-22 16:58:58 +00:00
Improve the behavior of get_slot_leases when no shares exist
This commit is contained in:
@ -412,10 +412,8 @@ class StorageServer(service.MultiService, Referenceable):
|
|||||||
|
|
||||||
:return: An iterable of the leases attached to this slot.
|
:return: An iterable of the leases attached to this slot.
|
||||||
"""
|
"""
|
||||||
si_dir = storage_index_to_dir(storage_index)
|
for _, share_filename in self._get_bucket_shares(storage_index):
|
||||||
bucketdir = os.path.join(self.sharedir, si_dir)
|
share = MutableShareFile(share_filename)
|
||||||
for share_filename in os.listdir(bucketdir):
|
|
||||||
share = MutableShareFile(os.path.join(bucketdir, share_filename))
|
|
||||||
return share.get_leases()
|
return share.get_leases()
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
@ -1398,6 +1398,17 @@ class MutableServer(unittest.TestCase):
|
|||||||
leases = list(ss.get_slot_leases(storage_index))
|
leases = list(ss.get_slot_leases(storage_index))
|
||||||
self.assertEqual([], leases)
|
self.assertEqual([], leases)
|
||||||
|
|
||||||
|
def test_get_slot_leases_empty_slot(self):
|
||||||
|
"""
|
||||||
|
When ``get_slot_leases`` is called for a slot for which the server has no
|
||||||
|
shares, it returns an empty iterable.
|
||||||
|
"""
|
||||||
|
ss = self.create(b"test_get_slot_leases_empty_slot")
|
||||||
|
self.assertEqual(
|
||||||
|
list(ss.get_slot_leases(b"si1")),
|
||||||
|
[],
|
||||||
|
)
|
||||||
|
|
||||||
def test_remove_non_present(self):
|
def test_remove_non_present(self):
|
||||||
"""
|
"""
|
||||||
A write vector which would remove a share completely can be applied on a
|
A write vector which would remove a share completely can be applied on a
|
||||||
|
Reference in New Issue
Block a user