mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Chdir in a block to dry up all method
- also, plays much nicer with FakeFS
This commit is contained in:
parent
08de898804
commit
6ddc27f5de
1 changed files with 13 additions and 13 deletions
|
@ -14,19 +14,19 @@ module Fog
|
|||
def all
|
||||
requires :directory
|
||||
if directory.collection.get(directory.key)
|
||||
pwd = Dir.pwd
|
||||
Dir.chdir(service.path_to(directory.key))
|
||||
data = Dir.glob('**/*').reject do |file|
|
||||
::File.directory?(file)
|
||||
end.map do |key|
|
||||
path = file_path(key)
|
||||
{
|
||||
:content_length => ::File.size(path),
|
||||
:key => key,
|
||||
:last_modified => ::File.mtime(path)
|
||||
}
|
||||
end
|
||||
Dir.chdir(pwd)
|
||||
data = []
|
||||
Dir.chdir(service.path_to(directory.key)) {
|
||||
data = Dir.glob('**/*').reject do |file|
|
||||
::File.directory?(file)
|
||||
end.map do |key|
|
||||
path = file_path(key)
|
||||
{
|
||||
:content_length => ::File.size(path),
|
||||
:key => key,
|
||||
:last_modified => ::File.mtime(path)
|
||||
}
|
||||
end
|
||||
}
|
||||
load(data)
|
||||
else
|
||||
nil
|
||||
|
|
Loading…
Reference in a new issue