Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/storage.py
Show First 20 Lines • Show All 202 Lines • ▼ Show 20 Lines | def content_add(self, content, db, cur): | ||||
- HashCollision in case of collision | - HashCollision in case of collision | ||||
- Any other exceptions raise by the db | - Any other exceptions raise by the db | ||||
Returns: | Returns: | ||||
Summary dict with the following key and associated values: | Summary dict with the following key and associated values: | ||||
content:add: New contents added | content:add: New contents added | ||||
content:bytes:add: Sum of the contents' length data | content:add:bytes: Sum of the contents' length data | ||||
skipped_content:add: New skipped contents (no data) added | skipped_content:add: New skipped contents (no data) added | ||||
""" | """ | ||||
content = [dict(c.items()) for c in content] # semi-shallow copy | content = [dict(c.items()) for c in content] # semi-shallow copy | ||||
now = datetime.datetime.now(tz=datetime.timezone.utc) | now = datetime.datetime.now(tz=datetime.timezone.utc) | ||||
for item in content: | for item in content: | ||||
item['ctime'] = now | item['ctime'] = now | ||||
if self.journal_writer: | if self.journal_writer: | ||||
Show All 32 Lines | def content_add(self, content, db, cur): | ||||
self._content_add_metadata( | self._content_add_metadata( | ||||
db, cur, content_with_data, content_without_data) | db, cur, content_with_data, content_without_data) | ||||
# Wait for objstorage addition before returning from the | # Wait for objstorage addition before returning from the | ||||
# transaction, bubbling up any exception | # transaction, bubbling up any exception | ||||
content_bytes_added = added_to_objstorage.result() | content_bytes_added = added_to_objstorage.result() | ||||
summary['content:bytes:add'] = content_bytes_added | summary['content:add:bytes'] = content_bytes_added | ||||
return summary | return summary | ||||
@db_transaction() | @db_transaction() | ||||
def content_update(self, content, keys=[], db=None, cur=None): | def content_update(self, content, keys=[], db=None, cur=None): | ||||
"""Update content blobs to the storage. Does nothing for unknown | """Update content blobs to the storage. Does nothing for unknown | ||||
contents or skipped ones. | contents or skipped ones. | ||||
Args: | Args: | ||||
▲ Show 20 Lines • Show All 1,527 Lines • Show Last 20 Lines |