Merge pull request #1034 from coreos-inc/fix404

Handle 404s on blob uploads
This commit is contained in:
josephschorr 2015-12-07 12:32:26 -05:00
commit 733b4cc8d7

View file

@ -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: