diff --git a/src/oca/ruby/OpenNebula/ImageRepository.rb b/src/oca/ruby/OpenNebula/ImageRepository.rb index cd297d78a4..071ab9346e 100644 --- a/src/oca/ruby/OpenNebula/ImageRepository.rb +++ b/src/oca/ruby/OpenNebula/ImageRepository.rb @@ -217,23 +217,21 @@ module OpenNebula # ######################################################################## def remove(source) - if File.exists?(source) + if !File.exists?(source) + return nil + end + + begin if File.directory?(source) - begin - FileUtils.rmdir(source) - rescue Exception => e - return OpenNebula::Error.new(e.message) - end + FileUtils.rmdir(source) else - begin - FileUtils.rm(source) - rescue Exception => e - return OpenNebula::Error.new(e.message) - end + FileUtils.rm(source) end + rescue Exception => e + return OpenNebula::Error.new(e.message) end return nil end end -end \ No newline at end of file +end