Add an exact abort and use it to send the expected response for 409s.

This commit is contained in:
Jake Moshenko 2014-06-11 16:55:38 -04:00
parent 78c5aec5b9
commit 7a5605a568
2 changed files with 28 additions and 19 deletions

View file

@ -10,7 +10,7 @@ from time import time
from app import storage as store, image_diff_queue
from auth.auth import process_auth, extract_namespace_repo_from_session
from util import checksums, changes
from util.http import abort
from util.http import abort, exact_abort
from auth.permissions import (ReadRepositoryPermission,
ModifyRepositoryPermission)
from data import model
@ -158,7 +158,7 @@ def put_image_layer(namespace, repository, image_id):
if (store.exists(layer_path) and not
image_is_uploading(repo_image)):
abort(409, 'Image already exists', issue='image-exists', image_id=image_id)
exact_abort(409, 'Image already exists')
profile.debug('Storing layer data')
@ -301,11 +301,8 @@ def get_image_json(namespace, repository, image_id, headers):
flask_abort(404)
profile.debug('Looking up repo layer size')
try:
size = (repo_image.storage and repo_image.storage.image_size) or repo_image.image_size
headers['X-Docker-Size'] = str(size)
except OSError:
pass
size = (repo_image.storage and repo_image.storage.image_size) or repo_image.image_size
headers['X-Docker-Size'] = str(size)
response = make_response(data, 200)
response.headers.extend(headers)
@ -423,7 +420,7 @@ def put_image_json(namespace, repository, image_id):
profile.debug('Checking if image already exists')
if (store.exists(json_path) and not
image_is_uploading(repo_image)):
abort(409, 'Image already exists', issue='image-exists', image_id=image_id)
exact_abort(409, 'Image already exists')
set_uploading_flag(repo_image, True)