1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-08 21:17:43 +03:00

Image delete function now copes with directories

This commit is contained in:
Tino Vázquez 2010-10-13 15:36:17 +02:00
parent 9d959c2e55
commit 3cc0f52988

View File

@ -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