Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/storage.py
Show First 20 Lines • Show All 510 Lines • ▼ Show 20 Lines | def content_find(self, content, db=None, cur=None): | ||||
raise ValueError('content keys must contain at least one of: ' | raise ValueError('content keys must contain at least one of: ' | ||||
'sha1, sha1_git, sha256, blake2s256') | 'sha1, sha1_git, sha256, blake2s256') | ||||
contents = db.content_find(sha1=content.get('sha1'), | contents = db.content_find(sha1=content.get('sha1'), | ||||
sha1_git=content.get('sha1_git'), | sha1_git=content.get('sha1_git'), | ||||
sha256=content.get('sha256'), | sha256=content.get('sha256'), | ||||
blake2s256=content.get('blake2s256'), | blake2s256=content.get('blake2s256'), | ||||
cur=cur) | cur=cur) | ||||
if contents: | return [dict(zip(db.content_find_cols, content)) | ||||
contents_list = [] | for content in contents] | ||||
for cont in contents: | |||||
contents_list.append(dict(zip(db.content_find_cols, cont))) | |||||
return contents_list | |||||
return None | |||||
@db_transaction() | @db_transaction() | ||||
def directory_add(self, directories, db, cur): | def directory_add(self, directories, db, cur): | ||||
"""Add directories to the storage | """Add directories to the storage | ||||
Args: | Args: | ||||
directories (iterable): iterable of dictionaries representing the | directories (iterable): iterable of dictionaries representing the | ||||
individual directories to add. Each dict has the following | individual directories to add. Each dict has the following | ||||
▲ Show 20 Lines • Show All 1,267 Lines • Show Last 20 Lines |