mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Missing HEAD method.
This commit is contained in:
parent
95ccf23d05
commit
475609602c
2 changed files with 12 additions and 12 deletions
|
@ -15,14 +15,14 @@ module Fog
|
||||||
|
|
||||||
model Fog::Storage::Ninefold::File
|
model Fog::Storage::Ninefold::File
|
||||||
|
|
||||||
def all(options = { })
|
def all(options = {})
|
||||||
requires :directory
|
requires :directory
|
||||||
directory ? ns = directory.key : ns = ''
|
directory ? ns = directory.key : ns = ''
|
||||||
ns = ns + '/' unless ns =~ /\/$/
|
ns = ns + '/' unless ns =~ /\/$/
|
||||||
data = connection.get_namespace(ns).body[:DirectoryList]
|
data = connection.get_namespace(ns).body[:DirectoryList]
|
||||||
data = { :DirectoryEntry => [] } if data.kind_of? String
|
data = {:DirectoryEntry => []} if data.kind_of? String
|
||||||
data[:DirectoryEntry] = [data[:DirectoryEntry]] if data[:DirectoryEntry].kind_of? Hash
|
data[:DirectoryEntry] = [data[:DirectoryEntry]] if data[:DirectoryEntry].kind_of? Hash
|
||||||
files = data[:DirectoryEntry].select { |de| de[:FileType] == 'regular' }
|
files = data[:DirectoryEntry].select {|de| de[:FileType] == 'regular'}
|
||||||
files.each do |s|
|
files.each do |s|
|
||||||
s[:directory] = directory
|
s[:directory] = directory
|
||||||
end
|
end
|
||||||
|
@ -32,10 +32,10 @@ module Fog
|
||||||
|
|
||||||
def get(key, &block)
|
def get(key, &block)
|
||||||
requires :directory
|
requires :directory
|
||||||
data = connection.get_namespace(directory.key + key, :parse => false) #, &block)
|
data = connection.get_namespace(directory.key + key, :parse => false)#, &block)
|
||||||
file_data = data.headers.merge({
|
file_data = data.headers.merge({
|
||||||
:body => data.body,
|
:body => data.body,
|
||||||
:key => key
|
:key => key
|
||||||
})
|
})
|
||||||
new(file_data)
|
new(file_data)
|
||||||
rescue Fog::Storage::Ninefold::NotFound
|
rescue Fog::Storage::Ninefold::NotFound
|
||||||
|
@ -53,15 +53,15 @@ module Fog
|
||||||
requires :directory
|
requires :directory
|
||||||
data = connection.head_object(directory.key + key, :parse => false)
|
data = connection.head_object(directory.key + key, :parse => false)
|
||||||
file_data = data.headers.merge({
|
file_data = data.headers.merge({
|
||||||
:body => data.body,
|
:body => data.body,
|
||||||
:key => key
|
:key => key
|
||||||
})
|
})
|
||||||
new(file_data)
|
new(file_data)
|
||||||
rescue Fog::Storage::Ninefold::NotFound
|
rescue Fog::Storage::Ninefold::NotFound
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def new(attributes = { })
|
def new(attributes = {})
|
||||||
requires :directory
|
requires :directory
|
||||||
super({ :directory => directory }.merge!(attributes))
|
super({ :directory => directory }.merge!(attributes))
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,15 +2,15 @@ module Fog
|
||||||
module Storage
|
module Storage
|
||||||
class Ninefold
|
class Ninefold
|
||||||
class Real
|
class Real
|
||||||
def head_object(namespace = '', options = {})
|
def head_object(namespace = '', options = { })
|
||||||
options = options.reject {|key, value| value.nil?}
|
options = options.reject { |key, value| value.nil? }
|
||||||
request({
|
request({
|
||||||
:expects => 200,
|
:expects => 200,
|
||||||
:method => 'HEAD',
|
:method => 'HEAD',
|
||||||
:path => "namespace/" + namespace,
|
:path => "namespace/" + namespace,
|
||||||
:query => {},
|
:query => {},
|
||||||
:parse => true
|
:parse => true
|
||||||
}.merge(options))
|
}.merge(options))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue