mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Fog::Storage::Local#directories#all: Don't break when :local_root folder is missing
This commit is contained in:
parent
b53068952e
commit
155c4503ed
2 changed files with 27 additions and 5 deletions
|
@ -10,12 +10,17 @@ module Fog
|
|||
model Fog::Storage::Local::Directory
|
||||
|
||||
def all
|
||||
data = Dir.entries(service.local_root).select do |entry|
|
||||
entry[0...1] != '.' && ::File.directory?(service.path_to(entry))
|
||||
end.map do |entry|
|
||||
{:key => entry}
|
||||
if ::File.directory?(service.local_root)
|
||||
data = Dir.entries(service.local_root).select do |entry|
|
||||
entry[0...1] != '.' && ::File.directory?(service.path_to(entry))
|
||||
end.map do |entry|
|
||||
{:key => entry}
|
||||
end
|
||||
load(data)
|
||||
else
|
||||
clear
|
||||
self
|
||||
end
|
||||
load(data)
|
||||
end
|
||||
|
||||
def get(key, options = {})
|
||||
|
|
17
tests/local/models/directories_tests.rb
Normal file
17
tests/local/models/directories_tests.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
Shindo.tests('Storage[:local] | directories', ["local"]) do
|
||||
|
||||
pending if Fog.mocking?
|
||||
|
||||
@options = { :local_root => "/tmp/fogtests" }
|
||||
@collection = Fog::Storage::Local.new(@options).directories
|
||||
|
||||
collection_tests(@collection, {:key => "fogdirtests"}, true)
|
||||
|
||||
tests("#all") do
|
||||
tests("succeeds when :local_root does not exist").succeeds do
|
||||
FileUtils.rm_rf(@options[:local_root])
|
||||
@collection.all
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Loading…
Add table
Reference in a new issue