1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[storage] auto-paginate for #each

closes #268
This commit is contained in:
geemus 2011-05-02 14:57:11 -07:00
parent 8a048c6c3f
commit 696b2ddb1e
2 changed files with 34 additions and 0 deletions

View file

@ -39,6 +39,23 @@ module Fog
end
end
alias :each_file_this_page :each
def each
if !block_given?
self
else
subset = dup.all
subset.each_file_this_page {|f| yield f}
while subset.is_truncated
subset = subset.all(:marker => subset.last.key)
subset.each_file_this_page {|f| yield f}
end
self
end
end
def get(key, options = {}, &block)
requires :directory
data = connection.get_object(directory.key, key, options, &block)

View file

@ -35,6 +35,23 @@ module Fog
end
end
alias :each_file_this_page :each
def each
if !block_given?
self
else
subset = dup.all
subset.each_file_this_page {|f| yield f}
until subset.empty? || subset.length == (subset.limit || 10000)
subset = subset.all(:marker => subset.last.key)
subset.each_file_this_page {|f| yield f}
end
self
end
end
def get(key, &block)
requires :directory
data = connection.get_object(directory.key, key, &block)