Changeset View
Changeset View
Standalone View
Standalone View
swh/vault/backend.py
Show First 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | def __init__(self, db, cache, scheduler, storage=None, **config): | ||||
) | ) | ||||
self._db = None | self._db = None | ||||
def get_db(self): | def get_db(self): | ||||
if self._db: | if self._db: | ||||
return self._db | return self._db | ||||
return BaseDb.from_pool(self._pool) | return BaseDb.from_pool(self._pool) | ||||
def put_db(self, db): | |||||
if db is not self._db: | |||||
db.put_conn() | |||||
@db_transaction() | @db_transaction() | ||||
def task_info(self, obj_type, obj_id, db=None, cur=None): | def task_info(self, obj_type, obj_id, db=None, cur=None): | ||||
"""Fetch information from a bundle""" | """Fetch information from a bundle""" | ||||
obj_id = hashutil.hash_to_bytes(obj_id) | obj_id = hashutil.hash_to_bytes(obj_id) | ||||
cur.execute(''' | cur.execute(''' | ||||
SELECT id, type, object_id, task_id, task_status, sticky, | SELECT id, type, object_id, task_id, task_status, sticky, | ||||
ts_created, ts_done, ts_last_access, progress_msg | ts_created, ts_done, ts_last_access, progress_msg | ||||
FROM vault_bundle | FROM vault_bundle | ||||
▲ Show 20 Lines • Show All 308 Lines • Show Last 20 Lines |