summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/chef/chef_fs/file_system.rb5
-rw-r--r--lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb2
-rw-r--r--lib/chef/chef_fs/file_system/cookbooks_dir.rb1
-rw-r--r--lib/chef/chef_fs/file_system/data_bags_dir.rb1
-rw-r--r--lib/chef/chef_fs/file_system/file_system_entry.rb9
-rw-r--r--lib/chef/chef_fs/file_system/multiplexed_dir.rb1
-rw-r--r--lib/chef/chef_fs/file_system/rest_list_dir.rb2
-rw-r--r--spec/integration/knife/download_spec.rb9
-rw-r--r--spec/integration/knife/upload_spec.rb15
9 files changed, 31 insertions, 14 deletions
diff --git a/lib/chef/chef_fs/file_system.rb b/lib/chef/chef_fs/file_system.rb
index e3c5c05077..f2478c4680 100644
--- a/lib/chef/chef_fs/file_system.rb
+++ b/lib/chef/chef_fs/file_system.rb
@@ -143,11 +143,6 @@ class Chef
found_result = true
new_dest_parent = get_or_create_parent(dest, options, ui, format_path)
child_error = copy_entries(src, dest, new_dest_parent, recurse_depth, options, ui, format_path)
- # Create the internal representation of the fact that the parent will now exist
- if !new_dest_parent.nil? and !new_dest_parent.parent.nil? and\
- !new_dest_parent.parent.children.include? new_dest_parent
- new_dest_parent.parent.children << new_dest_parent
- end
error ||= child_error
end
if !found_result && pattern.exact_path
diff --git a/lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb b/lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb
index 6396e031e1..61b3cfb5c7 100644
--- a/lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb
+++ b/lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb
@@ -54,7 +54,7 @@ class Chef
Dir.mkdir(path)
end
child = make_child_entry(name)
- @children << child
+ @children = nil
child
end
diff --git a/lib/chef/chef_fs/file_system/cookbooks_dir.rb b/lib/chef/chef_fs/file_system/cookbooks_dir.rb
index c6af933290..0a1e01c93b 100644
--- a/lib/chef/chef_fs/file_system/cookbooks_dir.rb
+++ b/lib/chef/chef_fs/file_system/cookbooks_dir.rb
@@ -63,6 +63,7 @@ class Chef
end
def create_child_from(other, options = {})
+ @children = nil
upload_cookbook_from(other, options)
end
diff --git a/lib/chef/chef_fs/file_system/data_bags_dir.rb b/lib/chef/chef_fs/file_system/data_bags_dir.rb
index 46c3c21cf6..d0404c284b 100644
--- a/lib/chef/chef_fs/file_system/data_bags_dir.rb
+++ b/lib/chef/chef_fs/file_system/data_bags_dir.rb
@@ -64,6 +64,7 @@ class Chef
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:create_child, self, e), "HTTP error creating child '#{name}': #{e}"
end
end
+ @children = nil
DataBagDir.new(name, self, true)
end
end
diff --git a/lib/chef/chef_fs/file_system/file_system_entry.rb b/lib/chef/chef_fs/file_system/file_system_entry.rb
index c9df58ceda..8b6549a664 100644
--- a/lib/chef/chef_fs/file_system/file_system_entry.rb
+++ b/lib/chef/chef_fs/file_system/file_system_entry.rb
@@ -47,13 +47,14 @@ class Chef
end
def create_child(child_name, file_contents=nil)
- result = FileSystemEntry.new(child_name, self)
+ child = FileSystemEntry.new(child_name, self)
if file_contents
- result.write(file_contents)
+ child.write(file_contents)
else
- Dir.mkdir(result.file_path)
+ Dir.mkdir(child.file_path)
end
- result
+ @children = nil
+ child
end
def dir?
diff --git a/lib/chef/chef_fs/file_system/multiplexed_dir.rb b/lib/chef/chef_fs/file_system/multiplexed_dir.rb
index a7a901e304..01d8bfe7f2 100644
--- a/lib/chef/chef_fs/file_system/multiplexed_dir.rb
+++ b/lib/chef/chef_fs/file_system/multiplexed_dir.rb
@@ -40,6 +40,7 @@ class Chef
end
def create_child(name, file_contents = nil)
+ @children = nil
write_dir.create_child(name, file_contents)
end
end
diff --git a/lib/chef/chef_fs/file_system/rest_list_dir.rb b/lib/chef/chef_fs/file_system/rest_list_dir.rb
index 594fec8ab6..7e4a33813b 100644
--- a/lib/chef/chef_fs/file_system/rest_list_dir.rb
+++ b/lib/chef/chef_fs/file_system/rest_list_dir.rb
@@ -89,6 +89,8 @@ class Chef
end
end
+ @children = nil
+
result
end
diff --git a/spec/integration/knife/download_spec.rb b/spec/integration/knife/download_spec.rb
index a3b3b875a8..eb5761bded 100644
--- a/spec/integration/knife/download_spec.rb
+++ b/spec/integration/knife/download_spec.rb
@@ -258,6 +258,15 @@ EOM
D\t/data_bags/x/z.json
EOM
end
+
+ it 'knife download /data_bags/x /data_bags/x/y.json downloads x once' do
+ knife('download /data_bags/x /data_bags/x/y.json').should_succeed <<EOM
+Created /data_bags
+Created /data_bags/x
+Created /data_bags/x/y.json
+Created /data_bags/x/z.json
+EOM
+ end
end
end
diff --git a/spec/integration/knife/upload_spec.rb b/spec/integration/knife/upload_spec.rb
index e0715f761a..770efb2d46 100644
--- a/spec/integration/knife/upload_spec.rb
+++ b/spec/integration/knife/upload_spec.rb
@@ -58,10 +58,10 @@ D\t/roles/x.json
D\t/users/admin.json
D\t/users/x.json
EOM
- end
+ end
- it 'knife upload --purge deletes everything' do
- knife('upload --purge /').should_succeed(<<EOM, :stderr => "WARNING: /environments/_default.json cannot be deleted (default environment cannot be modified).\n")
+ it 'knife upload --purge deletes everything' do
+ knife('upload --purge /').should_succeed(<<EOM, :stderr => "WARNING: /environments/_default.json cannot be deleted (default environment cannot be modified).\n")
Deleted extra entry /clients/chef-validator.json (purge is on)
Deleted extra entry /clients/chef-webui.json (purge is on)
Deleted extra entry /clients/x.json (purge is on)
@@ -76,7 +76,7 @@ EOM
knife('diff --name-status /').should_succeed <<EOM
D\t/environments/_default.json
EOM
- end
+ end
end
when_the_repository 'has an identical copy of each thing' do
@@ -239,6 +239,13 @@ EOM
EOM
JSON.parse(knife('raw /data/x/y').stdout, :create_additions => false).keys.sort.should == [ 'foo', 'id' ]
end
+
+ it 'knife upload /data_bags/x /data_bags/x/y.json uploads x once' do
+ knife('upload /data_bags/x /data_bags/x/y.json').should_succeed <<EOM
+Created /data_bags/x
+Created /data_bags/x/y.json
+EOM
+ end
end
when_the_repository 'has a data bag item with keys chef_type and data_bag' do