From b8bd92a64f15dddbf96dd2369db2b36f4fc8b302 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Mon, 7 Dec 2015 12:30:28 -0500 Subject: [PATCH] Handle 404s on blob uploads Fixes #1033 --- endpoints/v2/blob.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/endpoints/v2/blob.py b/endpoints/v2/blob.py index e5632c6d2..f5cfb8601 100644 --- a/endpoints/v2/blob.py +++ b/endpoints/v2/blob.py @@ -7,7 +7,8 @@ from app import storage, app from data import model, database from digest import digest_tools from endpoints.v2 import v2_bp, require_repo_read, require_repo_write, get_input_stream -from endpoints.v2.errors import BlobUnknown, BlobUploadInvalid, BlobUploadUnknown, Unsupported +from endpoints.v2.errors import (BlobUnknown, BlobUploadInvalid, BlobUploadUnknown, Unsupported, + NameUnknown) from auth.jwt_auth import process_jwt_auth from endpoints.decorators import anon_protect from util.cache import cache_control @@ -105,7 +106,12 @@ def _render_range(num_uploaded_bytes, with_bytes_prefix=True): def start_blob_upload(namespace, repo_name): location_name = storage.preferred_locations[0] new_upload_uuid, upload_metadata = storage.initiate_chunked_upload(location_name) - model.blob.initiate_upload(namespace, repo_name, new_upload_uuid, location_name, upload_metadata) + + try: + model.blob.initiate_upload(namespace, repo_name, new_upload_uuid, location_name, + upload_metadata) + except database.Repository.DoesNotExist: + raise NameUnknown() digest = request.args.get('digest', None) if digest is None: