Raise a 404 when we don't find a blob from swift

Currently if swift returns a 404, we fail and throw a 500. That's
less friendly. Let's throw a 404 instead.

Change-Id: I41b353d86eb5059cae54607adc31e19902f4af2e
This commit is contained in:
Monty Taylor 2019-10-09 15:38:36 -04:00
parent 56968a9c80
commit fec0efbcf4

View File

@ -291,6 +291,10 @@ class RegistryAPI:
self.log.debug('Manifest %s %s digest found %s',
repository, ref, manifest[ct])
data = self.storage.get_blob(namespace, manifest[ct])
if not data:
self.log.error(
'Blob %s %s not found', namespace, manifest[ct])
return self.not_found()
res.headers['Content-Type'] = ct
res.headers['Docker-Content-Digest'] = manifest[ct]
hasher = hashlib.sha256()