From 75d01c258487471e5c2265b87b46b080577eed91 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Mon, 18 Oct 2010 23:05:58 +0200 Subject: [PATCH] Minor modificatio to ImageRepository rm function --- src/oca/ruby/OpenNebula/ImageRepository.rb | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) 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