404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
|
# File 'lib/hpcloud/remote_resource.rb', line 404
def foreach(&block)
case @ftype
when :container_directory
regex = "^" + path + ".*"
when :container
regex = ".*"
else
regex = "^" + path + '$'
end
if @@limit.nil?
@@limit = Config.new.get_i(:storage_page_length, DEFAULT_STORAGE_PAGE_LENGTH)
end
total = 0
count = 0
marker = nil
begin
options = { :limit => @@limit, :marker => marker }
begin
result = @storage.get_container(@container, options)
rescue NoMethodError => e
@storage.directories.get(@container).files.each { |file|
yield ResourceFactory.create(@storage, ':' + @container + '/' + file.key)
}
return
end
total = result.['X-Container-Object-Count'].to_i
lode = result.body.length
count += lode
result.body.each { |x|
name = x['name']
if ! name.match(regex).nil?
res = ResourceFactory.create(@storage, ':' + @container + '/' + name)
res.path = name
res.etag = x['hash']
res.modified = x['last_modified']
res.size = x['bytes']
res.type = x['content_type']
yield res
end
marker = name
}
break if lode < @@limit
end until count >= total
end
|