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

[AWS|Glacier] make 1.8.7 friendly

This commit is contained in:
Frederick Cheung 2012-09-02 12:46:57 +01:00
parent bbb348281e
commit bbec81c4c9
10 changed files with 18 additions and 12 deletions

View file

@ -70,10 +70,14 @@ module Fog
if body.respond_to? :byteslice
digests_for_part = chunk_count.times.collect {|chunk_index| Digest::SHA256.digest(body.byteslice(chunk_index * MEGABYTE, MEGABYTE))}
else
old_encoding = body.encoding
body.force_encoding('BINARY')
if body.respond_to? :encoding
old_encoding = body.encoding
body.force_encoding('BINARY')
end
digests_for_part = chunk_count.times.collect {|chunk_index| Digest::SHA256.digest(body.slice(chunk_index * MEGABYTE, MEGABYTE))}
body.force_encoding(old_encoding)
if body.respond_to? :encoding
body.force_encoding(old_encoding)
end
end
reduce_digests(digests_for_part)
end

View file

@ -25,7 +25,7 @@ module Fog
:idempotent => true,
:headers => {},
:method => :delete,
:path => path,
:path => path
)
end
end

View file

@ -25,7 +25,7 @@ module Fog
:idempotent => true,
:headers => {},
:method => :delete,
:path => path,
:path => path
)
end
end

View file

@ -24,7 +24,7 @@ module Fog
:idempotent => true,
:headers => {},
:method => :delete,
:path => path,
:path => path
)
end
end

View file

@ -23,7 +23,7 @@ module Fog
:idempotent => true,
:headers => {},
:method => :delete,
:path => path,
:path => path
)
end
end

View file

@ -24,7 +24,7 @@ module Fog
:idempotent => true,
:headers => {},
:method => :get,
:path => path,
:path => path
)
end
end

View file

@ -31,7 +31,7 @@ module Fog
:idempotent => true,
:headers => headers,
:method => :get,
:path => path,
:path => path
))
end
end

View file

@ -24,7 +24,7 @@ module Fog
:idempotent => true,
:headers => {},
:method => :get,
:path => path,
:path => path
)
end
end

View file

@ -28,7 +28,7 @@ module Fog
:expects => 201,
:headers => headers,
:method => 'POST',
:path => path,
:path => path
)
end
end

View file

@ -5,7 +5,9 @@ Shindo.tests('AWS::Glacier | glacier tree hash calcuation', ['aws']) do
end
tests('tree_hash(multibyte characters)') do
body = ("\xC2\xA1".force_encoding('UTF-8') * 1024*1024)
body = ("\xC2\xA1" * 1024*1024)
body.force_encoding('UTF-8') if body.respond_to? :encoding
expected = Digest::SHA256.hexdigest(
Digest::SHA256.digest("\xC2\xA1" * 1024*512) + Digest::SHA256.digest("\xC2\xA1" * 1024*512)
)