summaryrefslogtreecommitdiff
path: root/lib/chef_zero
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2016-01-15 10:25:36 -0800
committerJohn Keiser <john@johnkeiser.com>2016-01-15 13:31:44 -0800
commitaa1f0797f90c322c8ebec640a798f82c95d7e558 (patch)
tree904c0f0fb69c36c6c8f5dc9b1919826d93c41fb2 /lib/chef_zero
parent0fdffc7918d944a0d58362ee70eef85bc1ab59da (diff)
downloadchef-zero-aa1f0797f90c322c8ebec640a798f82c95d7e558.tar.gz
Make hoovering and deleting parent dir work everywhere for cookbook_artifacts
Diffstat (limited to 'lib/chef_zero')
-rw-r--r--lib/chef_zero/endpoints/cookbook_artifacts_cookbook_identifier.rb2
-rw-r--r--lib/chef_zero/endpoints/cookbook_version_endpoint.rb16
2 files changed, 10 insertions, 8 deletions
diff --git a/lib/chef_zero/endpoints/cookbook_artifacts_cookbook_identifier.rb b/lib/chef_zero/endpoints/cookbook_artifacts_cookbook_identifier.rb
index 4d22d08..0dda65e 100644
--- a/lib/chef_zero/endpoints/cookbook_artifacts_cookbook_identifier.rb
+++ b/lib/chef_zero/endpoints/cookbook_artifacts_cookbook_identifier.rb
@@ -32,7 +32,7 @@ module ChefZero
delete_data(request)
# go through the recipes and delete stuff in the file store.
- hoover_unused_checksums(get_checksums(doomed_cookbook_json), request, 'cookbook_artifacts')
+ hoover_unused_checksums(get_checksums(doomed_cookbook_json), request)
# if this was the last revision, delete the directory so future requests will 404, instead of
# returning 200 with an empty list.
diff --git a/lib/chef_zero/endpoints/cookbook_version_endpoint.rb b/lib/chef_zero/endpoints/cookbook_version_endpoint.rb
index e78d44c..463cb70 100644
--- a/lib/chef_zero/endpoints/cookbook_version_endpoint.rb
+++ b/lib/chef_zero/endpoints/cookbook_version_endpoint.rb
@@ -58,8 +58,8 @@ module ChefZero
deleted_cookbook = get_data(request)
response = super(request)
- cookbook_name = request.rest_path[3]
- cookbook_path = request.rest_path[0..1] + ['cookbooks', cookbook_name]
+ # Last one out turns out the lights: delete /organizations/ORG/cookbooks/NAME if it no longer has versions
+ cookbook_path = request.rest_path[0..3]
if exists_data_dir?(request, cookbook_path) && list_data(request, cookbook_path).size == 0
delete_data_dir(request, cookbook_path)
end
@@ -85,11 +85,13 @@ module ChefZero
private
- def hoover_unused_checksums(deleted_checksums, request, data_type='cookbooks')
- data_store.list(request.rest_path[0..1] + [data_type]).each do |cookbook_name|
- data_store.list(request.rest_path[0..1] + [data_type, cookbook_name]).each do |version|
- cookbook = data_store.get(request.rest_path[0..1] + [data_type, cookbook_name, version], request)
- deleted_checksums = deleted_checksums - get_checksums(cookbook)
+ def hoover_unused_checksums(deleted_checksums, request)
+ %w(cookbooks cookbook_artifacts).each do |cookbook_type|
+ data_store.list(request.rest_path[0..1] + [cookbook_type]).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)
+ end
end
end
deleted_checksums.each do |checksum|