From 3cc0f5298874fbbb24765a43c53a7fc340533254 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tino=20V=C3=A1zquez?= Date: Wed, 13 Oct 2010 15:36:17 +0200 Subject: [PATCH] Image delete function now copes with directories --- src/oca/ruby/OpenNebula/ImageRepository.rb | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/oca/ruby/OpenNebula/ImageRepository.rb b/src/oca/ruby/OpenNebula/ImageRepository.rb index e26bace53c..cd297d78a4 100644 --- a/src/oca/ruby/OpenNebula/ImageRepository.rb +++ b/src/oca/ruby/OpenNebula/ImageRepository.rb @@ -218,10 +218,18 @@ module OpenNebula ######################################################################## def remove(source) if File.exists?(source) - begin - FileUtils.rm(source) - rescue Exception => e - return OpenNebula::Error.new(e.message) + if File.directory?(source) + begin + FileUtils.rmdir(source) + rescue Exception => e + return OpenNebula::Error.new(e.message) + end + else + begin + FileUtils.rm(source) + rescue Exception => e + return OpenNebula::Error.new(e.message) + end end end