Skip to content

Commit

Permalink
Fixed 500 during image pull when content is missing on the FS.
Browse files Browse the repository at this point in the history
closes pulp#555
  • Loading branch information
ipanova committed Jan 27, 2022
1 parent bc638e0 commit 385af7e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES/555.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed 500 during image pull when content is missing on the FS.
6 changes: 4 additions & 2 deletions pulp_container/app/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ async def _dispatch(file, headers):
The :class:`aiohttp.web.FileResponse` for the file.
"""
path = os.path.join(settings.MEDIA_ROOT, file.name)
if not os.path.exists(path):
raise PathNotResolved(path)

full_headers = MultiDict()

full_headers["Content-Type"] = headers["Content-Type"]
Expand All @@ -71,8 +75,6 @@ async def _dispatch(file, headers):
full_headers["Content-Disposition"] = "attachment; filename={n}".format(
n=os.path.basename(file.name)
)

path = os.path.join(settings.MEDIA_ROOT, file.name)
file_response = web.FileResponse(path, headers=full_headers)
return file_response

Expand Down

0 comments on commit 385af7e

Please sign in to comment.