879
879
return (row['object_count'] in (None, '', 0, '0')) and \
880
880
(float(row['delete_timestamp']) > float(row['put_timestamp']))
882
def get_info(self, include_metadata=False):
884
884
Get global data for the container.
886
:returns: sqlite.row of (account, container, created_at, put_timestamp,
887
delete_timestamp, object_count, bytes_used,
886
:returns: dict with keys: account, container, created_at,
887
put_timestamp, delete_timestamp, object_count, bytes_used,
888
888
reported_put_timestamp, reported_delete_timestamp,
889
reported_object_count, reported_bytes_used, hash, id)
889
reported_object_count, reported_bytes_used, hash, id
890
If include_metadata is set, metadata is included as a key
891
pointing to a dict of tuples of the metadata
892
894
self._commit_puts()
894
896
if not self.stale_reads_ok:
896
898
with self.get() as conn:
897
return conn.execute('''
898
SELECT account, container, created_at, put_timestamp,
899
delete_timestamp, object_count, bytes_used,
900
reported_put_timestamp, reported_delete_timestamp,
901
reported_object_count, reported_bytes_used, hash, id
901
metadata = ', metadata'
903
data = conn.execute('''
904
SELECT account, container, created_at, put_timestamp,
905
delete_timestamp, object_count, bytes_used,
906
reported_put_timestamp, reported_delete_timestamp,
907
reported_object_count, reported_bytes_used, hash, id
910
''' % metadata).fetchone()
911
except sqlite3.OperationalError, err:
912
if 'no such column: metadata' not in str(err):
914
data = conn.execute('''
915
SELECT account, container, created_at, put_timestamp,
916
delete_timestamp, object_count, bytes_used,
917
reported_put_timestamp, reported_delete_timestamp,
918
reported_object_count, reported_bytes_used, hash, id
919
FROM container_stat''').fetchone()
923
data['metadata'] = json.loads(data.get('metadata', ''))
925
data['metadata'] = {}
905
928
def reported(self, put_timestamp, delete_timestamp, object_count,
1395
1418
Get global data for the account.
1397
:returns: sqlite.row of (account, created_at, put_timestamp,
1420
:returns: dict with keys: account, created_at, put_timestamp,
1398
1421
delete_timestamp, container_count, object_count,
1399
bytes_used, hash, id)
1422
bytes_used, hash, id
1402
1425
self._commit_puts()
1404
1427
if not self.stale_reads_ok:
1406
1429
with self.get() as conn:
1407
return conn.execute('''
1430
return dict(conn.execute('''
1408
1431
SELECT account, created_at, put_timestamp, delete_timestamp,
1409
1432
container_count, object_count, bytes_used, hash, id
1410
1433
FROM account_stat
1413
1436
def list_containers_iter(self, limit, marker, end_marker, prefix,