mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-21 02:01:31 +00:00
Get rid of the "no such storage index" edge case, since it's not really necessary.
This commit is contained in:
parent
4b62ec082b
commit
457db8f992
@ -660,10 +660,7 @@ class HTTPServer(object):
|
||||
)
|
||||
def enumerate_mutable_shares(self, request, authorization, storage_index):
|
||||
"""List mutable shares for a storage index."""
|
||||
try:
|
||||
shares = self._storage_server.enumerate_mutable_shares(storage_index)
|
||||
except KeyError:
|
||||
raise _HTTPError(http.NOT_FOUND)
|
||||
shares = self._storage_server.enumerate_mutable_shares(storage_index)
|
||||
return self._send_encoded(request, shares)
|
||||
|
||||
|
||||
|
@ -691,15 +691,12 @@ class StorageServer(service.MultiService):
|
||||
return share
|
||||
|
||||
def enumerate_mutable_shares(self, storage_index: bytes) -> set[int]:
|
||||
"""List all share numbers for the given mutable.
|
||||
|
||||
Raises ``KeyError`` if the storage index is not known.
|
||||
"""
|
||||
"""Return all share numbers for the given mutable."""
|
||||
si_dir = storage_index_to_dir(storage_index)
|
||||
# shares exist if there is a file for them
|
||||
bucketdir = os.path.join(self.sharedir, si_dir)
|
||||
if not os.path.isdir(bucketdir):
|
||||
raise KeyError("Not found")
|
||||
return set()
|
||||
result = set()
|
||||
for sharenum_s in os.listdir(bucketdir):
|
||||
try:
|
||||
|
@ -1200,13 +1200,7 @@ class _HTTPStorageServer(object):
|
||||
# If shares list is empty, that means list all shares, so we need
|
||||
# to do a query to get that.
|
||||
if not shares:
|
||||
try:
|
||||
shares = yield mutable_client.list_shares(storage_index)
|
||||
except ClientException as e:
|
||||
if e.code == http.NOT_FOUND:
|
||||
shares = set()
|
||||
else:
|
||||
raise
|
||||
shares = yield mutable_client.list_shares(storage_index)
|
||||
|
||||
# Start all the queries in parallel:
|
||||
for share_number in shares:
|
||||
|
@ -1317,14 +1317,14 @@ class MutableServer(unittest.TestCase):
|
||||
|
||||
def test_enumerate_mutable_shares(self):
|
||||
"""
|
||||
``StorageServer.enumerate_mutable_shares()`` returns a set of share numbers
|
||||
for the given storage index, or raises ``KeyError`` if it does not exist at all.
|
||||
``StorageServer.enumerate_mutable_shares()`` returns a set of share
|
||||
numbers for the given storage index, or an empty set if it does not
|
||||
exist at all.
|
||||
"""
|
||||
ss = self.create("test_enumerate_mutable_shares")
|
||||
|
||||
# Initially, nothing exists:
|
||||
with self.assertRaises(KeyError):
|
||||
ss.enumerate_mutable_shares(b"si1")
|
||||
empty = ss.enumerate_mutable_shares(b"si1")
|
||||
|
||||
self.allocate(ss, b"si1", b"we1", b"le1", [0, 1, 4, 2], 12)
|
||||
shares0_1_2_4 = ss.enumerate_mutable_shares(b"si1")
|
||||
@ -1336,8 +1336,8 @@ class MutableServer(unittest.TestCase):
|
||||
ss.slot_testv_and_readv_and_writev(b"si1", secrets, {2: ([], [], 0)}, [])
|
||||
shares0_1_4 = ss.enumerate_mutable_shares(b"si1")
|
||||
self.assertEqual(
|
||||
(shares0_1_2_4, shares0_1_4),
|
||||
({0, 1, 2, 4}, {0, 1, 4})
|
||||
(empty, shares0_1_2_4, shares0_1_4),
|
||||
(set(), {0, 1, 2, 4}, {0, 1, 4})
|
||||
)
|
||||
|
||||
def test_bad_magic(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user