diff --git a/swh/storage/db.py b/swh/storage/db.py --- a/swh/storage/db.py +++ b/swh/storage/db.py @@ -78,7 +78,7 @@ yield from execute_values_generator( cur, """ select t.sha1, %s from (values %%s) as t (sha1) - left join content using (sha1) + inner join content using (sha1) """ % ', '.join(self.content_get_metadata_keys[1:]), ((sha1,) for sha1 in sha1s), ) diff --git a/swh/storage/in_memory.py b/swh/storage/in_memory.py --- a/swh/storage/in_memory.py +++ b/swh/storage/in_memory.py @@ -354,7 +354,9 @@ content: iterable of content identifiers (sha1) Returns: - an iterable with content metadata corresponding to the given ids + an iterable with content metadata corresponding to the given + ids + """ # FIXME: the return value should be a mapping from search key to found # content*s* @@ -369,15 +371,7 @@ del d['ctime'] yield d else: - # FIXME: should really be None - yield { - 'sha1': sha1, - 'sha1_git': None, - 'sha256': None, - 'blake2s256': None, - 'length': None, - 'status': None, - } + continue def content_find(self, content): if not set(content).intersection(DEFAULT_ALGORITHMS): diff --git a/swh/storage/storage.py b/swh/storage/storage.py --- a/swh/storage/storage.py +++ b/swh/storage/storage.py @@ -545,7 +545,9 @@ content: iterable of content identifiers (sha1) Returns: - an iterable with content metadata corresponding to the given ids + an iterable with content metadata corresponding to the given + ids + """ for metadata in db.content_get_metadata_from_sha1s(content, cur): yield dict(zip(db.content_get_metadata_keys, metadata)) diff --git a/swh/storage/tests/test_storage.py b/swh/storage/tests/test_storage.py --- a/swh/storage/tests/test_storage.py +++ b/swh/storage/tests/test_storage.py @@ -464,13 +464,7 @@ gen = swh_storage.content_get_metadata([missing_cont['sha1']]) - # All the metadata keys are None - missing_cont.pop('data') - for key in missing_cont: - if key != 'sha1': - missing_cont[key] = None - - assert list(gen) == [missing_cont] + assert list(gen) == [] def test_content_get_random(self, swh_storage): swh_storage.content_add([data.cont, data.cont2, data.cont3])