mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-19 11:16:24 +00:00
Improve the behavior of get_slot_leases when no shares exist
This commit is contained in:
parent
fce9657ce3
commit
de8199d3b0
@ -412,10 +412,8 @@ class StorageServer(service.MultiService, Referenceable):
|
||||
|
||||
:return: An iterable of the leases attached to this slot.
|
||||
"""
|
||||
si_dir = storage_index_to_dir(storage_index)
|
||||
bucketdir = os.path.join(self.sharedir, si_dir)
|
||||
for share_filename in os.listdir(bucketdir):
|
||||
share = MutableShareFile(os.path.join(bucketdir, share_filename))
|
||||
for _, share_filename in self._get_bucket_shares(storage_index):
|
||||
share = MutableShareFile(share_filename)
|
||||
return share.get_leases()
|
||||
return []
|
||||
|
||||
|
@ -1398,6 +1398,17 @@ class MutableServer(unittest.TestCase):
|
||||
leases = list(ss.get_slot_leases(storage_index))
|
||||
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):
|
||||
"""
|
||||
A write vector which would remove a share completely can be applied on a
|
||||
|
Loading…
Reference in New Issue
Block a user