diff options
author | Thom May <thom@chef.io> | 2016-08-01 19:42:50 +0100 |
---|---|---|
committer | Thom May <thom@may.lt> | 2016-08-01 19:42:50 +0100 |
commit | 3dce33d931409b8bebf224ffc20ce28d19a2899c (patch) | |
tree | 131ea17fd1633aa0c88b728f91406cd1dd68cbec | |
parent | e37ffed627248082b138bb87123dcb1e5be074b2 (diff) | |
download | chef-zero-3dce33d931409b8bebf224ffc20ce28d19a2899c.tar.gz |
Ensure that the cookbook version endpoint doesn't trip over itself
Signed-off-by: Thom May <thom@may.lt>
-rw-r--r-- | lib/chef_zero/endpoints/cookbook_version_endpoint.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/chef_zero/endpoints/cookbook_version_endpoint.rb b/lib/chef_zero/endpoints/cookbook_version_endpoint.rb index 55acd1a..e2dc726 100644 --- a/lib/chef_zero/endpoints/cookbook_version_endpoint.rb +++ b/lib/chef_zero/endpoints/cookbook_version_endpoint.rb @@ -95,9 +95,13 @@ module ChefZero cookbooks = [] end cookbooks.each do |cookbook_name| - data_store.list(request.rest_path[0..1] + [cookbook_type, cookbook_name]).each do |version| - cookbook = data_store.get(request.rest_path[0..1] + [cookbook_type, cookbook_name, version], request) - deleted_checksums = deleted_checksums - get_checksums(cookbook) + # as below, this can be racy. + begin + data_store.list(request.rest_path[0..1] + [cookbook_type, cookbook_name]).each do |version| + cookbook = data_store.get(request.rest_path[0..1] + [cookbook_type, cookbook_name, version], request) + deleted_checksums = deleted_checksums - get_checksums(cookbook) + end + rescue ChefZero::DataStore::DataNotFoundError end end end |