Revision bf903120 pithos/backends/simple.py
b/pithos/backends/simple.py | ||
---|---|---|
221 | 221 |
logger.debug("list_containers: %s %s %s %s", account, marker, limit, until) |
222 | 222 |
if user != account: |
223 | 223 |
raise NotAllowedError |
224 |
return self._list_objects(account, '', '/', marker, limit, False, [], until) |
|
224 |
return self._list_objects(account, '', '/', marker, limit, False, [], False, until)
|
|
225 | 225 |
|
226 | 226 |
def get_container_meta(self, user, account, container, until=None): |
227 | 227 |
"""Return a dictionary with the container metadata.""" |
... | ... | |
333 | 333 |
self.con.execute(sql, (path,)) |
334 | 334 |
self._copy_version(user, account, account, True, True) # New account version (for timestamp update). |
335 | 335 |
|
336 |
def list_objects(self, user, account, container, prefix='', delimiter=None, marker=None, limit=10000, virtual=True, keys=[], until=None): |
|
336 |
def list_objects(self, user, account, container, prefix='', delimiter=None, marker=None, limit=10000, virtual=True, keys=[], trash=False, until=None):
|
|
337 | 337 |
"""Return a list of objects existing under a container.""" |
338 | 338 |
|
339 |
logger.debug("list_objects: %s %s %s %s %s %s %s", account, container, prefix, delimiter, marker, limit, until)
|
|
339 |
logger.debug("list_objects: %s %s %s %s %s %s %s %s %s %s", account, container, prefix, delimiter, marker, limit, virtual, keys, trash, until)
|
|
340 | 340 |
if user != account: |
341 | 341 |
raise NotAllowedError |
342 | 342 |
path, version_id, mtime = self._get_containerinfo(account, container, until) |
343 |
return self._list_objects(path, prefix, delimiter, marker, limit, virtual, keys, until) |
|
343 |
return self._list_objects(path, prefix, delimiter, marker, limit, virtual, keys, trash, until)
|
|
344 | 344 |
|
345 | 345 |
def list_object_meta(self, user, account, container, until=None): |
346 | 346 |
"""Return a list with all the container's object meta keys.""" |
... | ... | |
854 | 854 |
self.con.execute(sql, (path,)) |
855 | 855 |
self.con.commit() |
856 | 856 |
|
857 |
def _list_objects(self, path, prefix='', delimiter=None, marker=None, limit=10000, virtual=True, keys=[], until=None): |
|
857 |
def _list_objects(self, path, prefix='', delimiter=None, marker=None, limit=10000, virtual=True, keys=[], trash=False, until=None):
|
|
858 | 858 |
cont_prefix = path + '/' |
859 |
|
|
860 |
if trash: |
|
861 |
table = '''select version_id, name, strftime('%s', tstamp) as tstamp, size from versions v |
|
862 |
where hide = 1''' % ('%s',) |
|
863 |
if until is not None: |
|
864 |
table += ''' and tstamp <= datetime(%s, 'unixepoch')''' % (until,) |
|
865 |
else: |
|
866 |
table = self._sql_until(until) |
|
859 | 867 |
if keys and len(keys) > 0: |
860 | 868 |
sql = '''select distinct o.name, o.version_id from (%s) o, metadata m where o.name like ? and |
861 | 869 |
m.version_id = o.version_id and m.key in (%s) order by o.name''' |
862 |
sql = sql % (self._sql_until(until), ', '.join('?' * len(keys)))
|
|
870 |
sql = sql % (table, ', '.join('?' * len(keys)))
|
|
863 | 871 |
param = (cont_prefix + prefix + '%',) + tuple(keys) |
864 | 872 |
else: |
865 | 873 |
sql = 'select name, version_id from (%s) where name like ? order by name' |
866 |
sql = sql % self._sql_until(until)
|
|
874 |
sql = sql % (table,)
|
|
867 | 875 |
param = (cont_prefix + prefix + '%',) |
868 | 876 |
c = self.con.execute(sql, param) |
869 | 877 |
objects = [(x[0][len(cont_prefix):], x[1]) for x in c.fetchall()] |
Also available in: Unified diff