39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/fog/local/models/storage/file.rb', line 39
def destroy
requires :directory, :key
::File.delete(path) if ::File.exists?(path)
dirs = path.split(::File::SEPARATOR)[0...-1]
dirs.length.times do |index|
dir_path = dirs[0..-index].join(::File::SEPARATOR)
if dir_path.empty?
next
end
if dir_path == connection.path_to(directory.key)
break
end
pwd = Dir.pwd
if ::Dir.exists?(dir_path)
Dir.chdir(dir_path)
if Dir.glob('*').empty?
Dir.rmdir(dir_path)
end
Dir.chdir(pwd)
end
end
true
end
|