summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanielsdeleo <dan@chef.io>2016-02-05 16:01:09 -0800
committerdanielsdeleo <dan@chef.io>2016-02-16 15:26:43 -0800
commitbb0f14e5021bb78c9f9fe75f117096751fa44e8c (patch)
tree84546873693704922f60412cad1b64b0d9d2a14f
parent074f62608684f34d0a88d6fa446694dcb3c9d43d (diff)
downloadchef-bb0f14e5021bb78c9f9fe75f117096751fa44e8c.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.rb61
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