Merge "Fix use of delimiter in account listings"
This commit is contained in:
commit
ca172887a6
@ -380,6 +380,7 @@ class AccountBroker(DatabaseBroker):
|
|||||||
|
|
||||||
:returns: list of tuples of (name, object_count, bytes_used, 0)
|
:returns: list of tuples of (name, object_count, bytes_used, 0)
|
||||||
"""
|
"""
|
||||||
|
delim_force_gte = False
|
||||||
(marker, end_marker, prefix, delimiter) = utf8encode(
|
(marker, end_marker, prefix, delimiter) = utf8encode(
|
||||||
marker, end_marker, prefix, delimiter)
|
marker, end_marker, prefix, delimiter)
|
||||||
self._commit_puts_stale_ok()
|
self._commit_puts_stale_ok()
|
||||||
@ -392,12 +393,17 @@ class AccountBroker(DatabaseBroker):
|
|||||||
query = """
|
query = """
|
||||||
SELECT name, object_count, bytes_used, 0
|
SELECT name, object_count, bytes_used, 0
|
||||||
FROM container
|
FROM container
|
||||||
WHERE deleted = 0 AND """
|
WHERE """
|
||||||
query_args = []
|
query_args = []
|
||||||
if end_marker:
|
if end_marker:
|
||||||
query += ' name < ? AND'
|
query += ' name < ? AND'
|
||||||
query_args.append(end_marker)
|
query_args.append(end_marker)
|
||||||
if marker and marker >= prefix:
|
if delim_force_gte:
|
||||||
|
query += ' name >= ? AND'
|
||||||
|
query_args.append(marker)
|
||||||
|
# Always set back to False
|
||||||
|
delim_force_gte = False
|
||||||
|
elif marker and marker >= prefix:
|
||||||
query += ' name > ? AND'
|
query += ' name > ? AND'
|
||||||
query_args.append(marker)
|
query_args.append(marker)
|
||||||
elif prefix:
|
elif prefix:
|
||||||
@ -437,6 +443,8 @@ class AccountBroker(DatabaseBroker):
|
|||||||
end = name.find(delimiter, len(prefix))
|
end = name.find(delimiter, len(prefix))
|
||||||
if end > 0:
|
if end > 0:
|
||||||
marker = name[:end] + chr(ord(delimiter) + 1)
|
marker = name[:end] + chr(ord(delimiter) + 1)
|
||||||
|
# we want result to be inclusive of delim+1
|
||||||
|
delim_force_gte = True
|
||||||
dir_name = name[:end + 1]
|
dir_name = name[:end + 1]
|
||||||
if dir_name != orig_marker:
|
if dir_name != orig_marker:
|
||||||
results.append([dir_name, 0, 0, 1])
|
results.append([dir_name, 0, 0, 1])
|
||||||
|
@ -486,6 +486,11 @@ class TestAccountBroker(unittest.TestCase):
|
|||||||
POLICIES.default.idx)
|
POLICIES.default.idx)
|
||||||
broker.put_container('a-b', Timestamp(time()).internal, 0, 0, 0,
|
broker.put_container('a-b', Timestamp(time()).internal, 0, 0, 0,
|
||||||
POLICIES.default.idx)
|
POLICIES.default.idx)
|
||||||
|
# NB: ord(".") == ord("-") + 1
|
||||||
|
broker.put_container('a.', Timestamp(time()).internal, 0, 0, 0,
|
||||||
|
POLICIES.default.idx)
|
||||||
|
broker.put_container('a.b', Timestamp(time()).internal, 0, 0, 0,
|
||||||
|
POLICIES.default.idx)
|
||||||
broker.put_container('b', Timestamp(time()).internal, 0, 0, 0,
|
broker.put_container('b', Timestamp(time()).internal, 0, 0, 0,
|
||||||
POLICIES.default.idx)
|
POLICIES.default.idx)
|
||||||
broker.put_container('b-a', Timestamp(time()).internal, 0, 0, 0,
|
broker.put_container('b-a', Timestamp(time()).internal, 0, 0, 0,
|
||||||
@ -495,20 +500,16 @@ class TestAccountBroker(unittest.TestCase):
|
|||||||
broker.put_container('c', Timestamp(time()).internal, 0, 0, 0,
|
broker.put_container('c', Timestamp(time()).internal, 0, 0, 0,
|
||||||
POLICIES.default.idx)
|
POLICIES.default.idx)
|
||||||
listing = broker.list_containers_iter(15, None, None, None, None)
|
listing = broker.list_containers_iter(15, None, None, None, None)
|
||||||
self.assertEqual(len(listing), 10)
|
|
||||||
self.assertEqual([row[0] for row in listing],
|
self.assertEqual([row[0] for row in listing],
|
||||||
['a', 'a-', 'a-a', 'a-a-a', 'a-a-b', 'a-b', 'b',
|
['a', 'a-', 'a-a', 'a-a-a', 'a-a-b', 'a-b', 'a.',
|
||||||
'b-a', 'b-b', 'c'])
|
'a.b', 'b', 'b-a', 'b-b', 'c'])
|
||||||
listing = broker.list_containers_iter(15, None, None, '', '-')
|
listing = broker.list_containers_iter(15, None, None, '', '-')
|
||||||
self.assertEqual(len(listing), 5)
|
|
||||||
self.assertEqual([row[0] for row in listing],
|
self.assertEqual([row[0] for row in listing],
|
||||||
['a', 'a-', 'b', 'b-', 'c'])
|
['a', 'a-', 'a.', 'a.b', 'b', 'b-', 'c'])
|
||||||
listing = broker.list_containers_iter(15, None, None, 'a-', '-')
|
listing = broker.list_containers_iter(15, None, None, 'a-', '-')
|
||||||
self.assertEqual(len(listing), 4)
|
|
||||||
self.assertEqual([row[0] for row in listing],
|
self.assertEqual([row[0] for row in listing],
|
||||||
['a-', 'a-a', 'a-a-', 'a-b'])
|
['a-', 'a-a', 'a-a-', 'a-b'])
|
||||||
listing = broker.list_containers_iter(15, None, None, 'b-', '-')
|
listing = broker.list_containers_iter(15, None, None, 'b-', '-')
|
||||||
self.assertEqual(len(listing), 2)
|
|
||||||
self.assertEqual([row[0] for row in listing], ['b-a', 'b-b'])
|
self.assertEqual([row[0] for row in listing], ['b-a', 'b-b'])
|
||||||
|
|
||||||
def test_chexor(self):
|
def test_chexor(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user