diff options
author | danielsdeleo <dan@chef.io> | 2016-02-05 16:01:09 -0800 |
---|---|---|
committer | danielsdeleo <dan@chef.io> | 2016-02-16 11:41:03 -0800 |
commit | 30d99cd6729af1845ea8acfbd88114e84bc41f42 (patch) | |
tree | bca4075524f01d5896dc1c2151562b19abb30daf | |
parent | 0e8d4fe1b26d9a1482a22e8233fbfa05e6beb5bd (diff) | |
download | chef-30d99cd6729af1845ea8acfbd88114e84bc41f42.tar.gz |
Remove unused code and logic branches from inlined code
-rw-r--r-- | lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbooks_dir.rb | 61 |
1 files changed, 28 insertions, 33 deletions
diff --git a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbooks_dir.rb b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbooks_dir.rb index b584ee0eb8..9c50d162ef 100644 --- a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbooks_dir.rb +++ b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbooks_dir.rb @@ -215,54 +215,49 @@ class Chef if child.exists? raise Chef::ChefFS::FileSystem::AlreadyExistsError.new(:create_child, child) end - if file_contents - child.write(file_contents) - else - begin - Dir.mkdir(child.file_path) - rescue Errno::EEXIST - raise Chef::ChefFS::FileSystem::AlreadyExistsError.new(:create_child, child) - end + begin + Dir.mkdir(child.file_path) + rescue Errno::EEXIST + raise Chef::ChefFS::FileSystem::AlreadyExistsError.new(:create_child, child) end child end - def dir? - File.directory?(file_path) - end + # this becomes unused when you remove code branches that we cannot hit + ## def dir? + ## File.directory?(file_path) + ## end def delete(recurse) - begin - if dir? - if !recurse - raise MustDeleteRecursivelyError.new(self, $!) - end - FileUtils.rm_r(file_path) - else - File.delete(file_path) + if exists? + if !recurse + raise MustDeleteRecursivelyError.new(self, $!) end - rescue Errno::ENOENT + FileUtils.rm_r(file_path) + else raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!) end end def exists? - File.exists?(file_path) && (parent.nil? || parent.can_have_child?(name, dir?)) + File.exists?(file_path) # && (parent.nil? || parent.can_have_child?(name, dir?)) end - def read - begin - File.open(file_path, "rb") {|f| f.read} - rescue Errno::ENOENT - raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!) - end - end + # unused + ## def read + ## begin + ## File.open(file_path, "rb") {|f| f.read} + ## rescue Errno::ENOENT + ## raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!) + ## end + ## end - def write(content) - File.open(file_path, "wb") do |file| - file.write(content) - end - end + # unused + ## def write(content) + ## File.open(file_path, "wb") do |file| + ## file.write(content) + ## end + ## end ## protected |