"""
return
- def list_objects(self, user, account, container, prefix='', delimiter=None, marker=None, limit=10000, virtual=True, domain=None, keys=[], shared=False, until=None):
+ def list_objects(self, user, account, container, prefix='', delimiter=None, marker=None, limit=10000, virtual=True, domain=None, keys=[], shared=False, until=None, size_range=None):
"""Return a list of object (name, version_id) tuples existing under a container.
Parameters:
value queries, where 'op' can be one of =, !=, <=, >=, <, >
'shared': Only list objects with permissions set
+
+ 'size_range': Include objects with byte size in (from, to).
+ Use None to specify unlimited
Raises:
NotAllowedError: Operation not permitted
def latest_version_list(self, parent, prefix='', delimiter=None,
start='', limit=10000, before=inf,
- except_cluster=0, pathq=[], domain=None, filterq=[]):
+ except_cluster=0, pathq=[], domain=None, filterq=[], sizeq=None):
"""Return a (list of (path, serial) tuples, list of common prefixes)
for the current versions of the paths with the given parent,
matching the following criteria.
key ?op value
the attribute with this key satisfies the value
where ?op is one of ==, != <=, >=, <, >.
+
+ h. the size is in the range set by sizeq
The list of common prefixes includes the prefixes
matching up to the first delimiter after prefix,
conj = []
for x in pathq:
conj.append(n.c.path.like(self.escape_like(x) + '%', escape='\\'))
-
if conj:
s = s.where(or_(*conj))
+ if sizeq and len(sizeq) == 2:
+ if sizeq[0]:
+ s = s.where(v.c.size >= sizeq[0])
+ if sizeq[1]:
+ s = s.where(v.c.size < sizeq[1])
+
if domain and filterq:
a = self.attributes.alias('a')
included, excluded, opers = parse_filters(filterq)
return subq, args
+ def _construct_size(self, sizeq):
+ if not sizeq or len(sizeq) != 2:
+ return None, None
+
+ subq = ''
+ args = []
+ if sizeq[0]:
+ subq += " and v.size >= ?"
+ args += [sizeq[0]]
+ if sizeq[1]:
+ subq += " and v.size < ?"
+ args += [sizeq[1]]
+
+ return subq, args
+
def latest_attribute_keys(self, parent, domain, before=inf, except_cluster=0, pathq=[]):
"""Return a list with all keys pairs defined
for all latest versions under parent that
def latest_version_list(self, parent, prefix='', delimiter=None,
start='', limit=10000, before=inf,
- except_cluster=0, pathq=[], domain=None, filterq=[]):
+ except_cluster=0, pathq=[], domain=None, filterq=[], sizeq=None):
"""Return a (list of (path, serial) tuples, list of common prefixes)
for the current versions of the paths with the given parent,
matching the following criteria.
key ?op value
the attribute with this key satisfies the value
where ?op is one of =, != <=, >=, <, >.
+
+ h. the size is in the range set by sizeq
The list of common prefixes includes the prefixes
matching up to the first delimiter after prefix,
if subq is not None:
q += subq
args += subargs
+ subq, subargs = self._construct_size(sizeq)
+ if subq is not None:
+ q += subq
+ args += subargs
subq, subargs = self._construct_filters(domain, filterq)
if subq is not None:
q += subq
# copyright notice, this list of conditions and the following
# disclaimer.
#
-# 2. Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following
+# 2. Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
self.node.node_remove(node)
@backend_method
- def list_objects(self, user, account, container, prefix='', delimiter=None, marker=None, limit=10000, virtual=True, domain=None, keys=[], shared=False, until=None):
+ def list_objects(self, user, account, container, prefix='', delimiter=None, marker=None, limit=10000, virtual=True, domain=None, keys=[], shared=False, until=None, size_range=None):
"""Return a list of objects existing under a container."""
logger.debug("list_objects: %s %s %s %s %s %s %s %s %s %s %s", account, container, prefix, delimiter, marker, limit, virtual, domain, keys, shared, until)
if not allowed:
return []
path, node = self._lookup_container(account, container)
- return self._list_objects(node, path, prefix, delimiter, marker, limit, virtual, domain, keys, until, allowed)
+ return self._list_objects(node, path, prefix, delimiter, marker, limit, virtual, domain, keys, until, size_range, allowed)
@backend_method
def list_object_meta(self, user, account, container, domain, until=None):
limit = 10000
return start, limit
- def _list_objects(self, parent, path, prefix='', delimiter=None, marker=None, limit=10000, virtual=True, domain=None, keys=[], until=None, allowed=[]):
+ def _list_objects(self, parent, path, prefix='', delimiter=None, marker=None, limit=10000, virtual=True, domain=None, keys=[], until=None, size_range=None, allowed=[]):
cont_prefix = path + '/'
prefix = cont_prefix + prefix
start = cont_prefix + marker if marker else None
before = until if until is not None else inf
filterq = keys if domain else []
+ sizeq = size_range
- objects, prefixes = self.node.latest_version_list(parent, prefix, delimiter, start, limit, before, CLUSTER_DELETED, allowed, domain, filterq)
+ objects, prefixes = self.node.latest_version_list(parent, prefix, delimiter, start, limit, before, CLUSTER_DELETED, allowed, domain, filterq, sizeq)
objects.extend([(p, None) for p in prefixes] if virtual else [])
objects.sort(key=lambda x: x[0])
objects = [(x[0][len(cont_prefix):], x[1]) for x in objects]