Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/postgresql/storage.py
Show First 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | except psycopg2.errors.UniqueViolation: | ||||
raise | raise | ||||
except VALIDATION_EXCEPTIONS as e: | except VALIDATION_EXCEPTIONS as e: | ||||
raise StorageArgumentException(str(e)) | raise StorageArgumentException(str(e)) | ||||
class Storage: | class Storage: | ||||
"""SWH storage datastore proxy, encompassing DB and object storage""" | """SWH storage datastore proxy, encompassing DB and object storage""" | ||||
current_version: int = 186 | current_version: int = 187 | ||||
def __init__( | def __init__( | ||||
self, | self, | ||||
db, | db, | ||||
objstorage, | objstorage, | ||||
min_pool_conns=1, | min_pool_conns=1, | ||||
max_pool_conns=10, | max_pool_conns=10, | ||||
journal_writer=None, | journal_writer=None, | ||||
▲ Show 20 Lines • Show All 682 Lines • ▼ Show 20 Lines | class Storage: | ||||
def extid_add(self, ids: List[ExtID], *, db: Db, cur=None) -> Dict[str, int]: | def extid_add(self, ids: List[ExtID], *, db: Db, cur=None) -> Dict[str, int]: | ||||
extid = [ | extid = [ | ||||
{ | { | ||||
"extid": extid.extid, | "extid": extid.extid, | ||||
"extid_type": extid.extid_type, | "extid_type": extid.extid_type, | ||||
"extid_version": getattr(extid, "extid_version", 0), | "extid_version": getattr(extid, "extid_version", 0), | ||||
"target": extid.target.object_id, | "target": extid.target.object_id, | ||||
"target_type": extid.target.object_type.name.lower(), # arghh | "target_type": extid.target.object_type.name.lower(), # arghh | ||||
"payload_type": extid.payload_type, | |||||
"payload": extid.payload, | |||||
} | } | ||||
for extid in ids | for extid in ids | ||||
] | ] | ||||
db.mktemp("extid", cur) | db.mktemp("extid", cur) | ||||
self.journal_writer.extid_add(ids) | self.journal_writer.extid_add(ids) | ||||
db.copy_to(extid, "tmp_extid", db.extid_cols, cur) | db.copy_to(extid, "tmp_extid", db.extid_cols, cur) | ||||
▲ Show 20 Lines • Show All 894 Lines • Show Last 20 Lines |