diff options
author | Steven Danna <steve@opscode.com> | 2014-06-18 16:43:14 -0700 |
---|---|---|
committer | Steven Danna <steve@opscode.com> | 2014-06-18 16:47:23 -0700 |
commit | 937da3a2e3b1afd970acbc596d42fee372e056c1 (patch) | |
tree | d20e6dde7325c61e844186c13a08202068f66ee0 | |
parent | cbe69c74eada5957d409f5d47694bd961951226e (diff) | |
download | chef-937da3a2e3b1afd970acbc596d42fee372e056c1.tar.gz |
[chef_fs/file_system] Ignore missing entry at destination when purgingssd/purge-ignore-missing-on-purge
If a user attempts to call #copy_to with a path that does not exist at
either the source or destination and :purge set to true, we currently
fail with an error trying to delete the non-existent entry at the
destination.
This patch ignores that failure.
-rw-r--r-- | lib/chef/chef_fs/file_system.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/chef/chef_fs/file_system.rb b/lib/chef/chef_fs/file_system.rb index 9fe726744e..ffbe274864 100644 --- a/lib/chef/chef_fs/file_system.rb +++ b/lib/chef/chef_fs/file_system.rb @@ -285,8 +285,12 @@ class Chef if options[:dry_run] ui.output "Would delete #{dest_path}" if ui else - dest_entry.delete(true) - ui.output "Deleted extra entry #{dest_path} (purge is on)" if ui + begin + dest_entry.delete(true) + ui.output "Deleted extra entry #{dest_path} (purge is on)" if ui + rescue Chef::ChefFS::FileSystem::NotFoundError + ui.output "Entry #{dest_path} does not exist. Nothing to do. (purge is on)" if ui + end end else ui.output ("Not deleting extra entry #{dest_path} (purge is off)") if ui |