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

[rackspace|storage] fixes for attribute alias discrepancies

This commit is contained in:
geemus 2010-10-18 11:09:19 -07:00
parent d8e9ff71a6
commit 6037202b3b
3 changed files with 14 additions and 9 deletions

View file

@ -15,11 +15,16 @@ module Fog
end end
def get(key, options = {}) def get(key, options = {})
data = connection.get_container(key, options).body data = connection.get_container(key, options)
directory = new(:key => key) directory = new(:key => key)
for key, value in data.headers
if ['X-Container-Bytes-Used', 'X-Container-Object-Count'].include?(key)
directory.merge_attributes(key => value)
end
end
directory.files.merge_attributes(options) directory.files.merge_attributes(options)
directory.files.instance_variable_set(:@loaded, true) directory.files.instance_variable_set(:@loaded, true)
data.each do |file| data.body.each do |file|
directory.files << directory.files.new(file) directory.files << directory.files.new(file)
end end
directory directory

View file

@ -12,8 +12,8 @@ module Fog
identity :key, :aliases => 'name' identity :key, :aliases => 'name'
attribute :bytes attribute :bytes, :aliases => 'X-Container-Bytes-Used'
attribute :count attribute :count, :aliases => 'X-Container-Object-Count'
def destroy def destroy
requires :key requires :key

View file

@ -6,13 +6,13 @@ module Fog
class File < Fog::Model class File < Fog::Model
identity :key, :aliases => 'Key' identity :key, :aliases => 'name'
attr_writer :body attr_writer :body
attribute :content_length, :aliases => 'Content-Length' attribute :content_length, :aliases => ['bytes', 'Content-Length']
attribute :content_type, :aliases => 'Content-Type' attribute :content_type, :aliases => ['content_type', 'Content-Type']
attribute :etag, :aliases => 'Etag' attribute :etag, :aliases => ['hash', 'Etag']
attribute :last_modified, :aliases => 'Last-Modified' attribute :last_modified, :aliases => ['last_modified', 'Last-Modified']
def body def body
@body ||= if last_modified @body ||= if last_modified