lib/fog/azurerm/requests/storage/get_blob.rb in gitlab-fog-azure-rm-1.2.0 vs lib/fog/azurerm/requests/storage/get_blob.rb in gitlab-fog-azure-rm-1.3.0
- old
+ new
@@ -3,11 +3,11 @@
class AzureRM
# This class provides the actual implemention for service calls.
class Real
BLOCK_SIZE = 32 * 1024 * 1024 # 32 MB
- def get_blob_with_block_given(container_name, blob_name, options, &_block)
+ def get_blob_with_block_given(container_name, blob_name, options, &block)
options[:request_id] = SecureRandom.uuid
msg = "get_blob_with_block_given: blob #{blob_name} in the container #{container_name}. options: #{options}"
Fog::Logger.debug msg
begin
@@ -17,22 +17,22 @@
raise_azure_exception(ex, msg)
end
content_length = blob.properties[:content_length]
if content_length.zero?
- Proc.new.call('', 0, 0)
+ block.call('', 0, 0)
return [blob, '']
end
start_range = 0
end_range = content_length - 1
start_range = options[:start_range] if options[:start_range]
end_range = options[:end_range] if options[:end_range]
raise ArgumentError.new(':end_range MUST be greater than :start_range') if start_range > end_range
if start_range == end_range
- Proc.new.call('', 0, 0)
+ block.call('', 0, 0)
return [blob, '']
end
buffer_size = BLOCK_SIZE
buffer_size = options[:block_size] if options[:block_size]
@@ -53,11 +53,11 @@
rescue Azure::Core::Http::HTTPError => ex
raise 'NotFound' if ex.message.include?('(404)')
raise_azure_exception(ex, msg)
end
- Proc.new.call(content, end_range - buffer_end_range, total_bytes)
+ block.call(content, end_range - buffer_end_range, total_bytes)
buffer_start_range += buffer_size
end
# No need to return content when block is given.
[blob, '']
end
@@ -82,11 +82,11 @@
end
end
# This class provides the mock implementation for unit tests.
class Mock
- def get_blob(_container_name, _blob_name, _options = {}, &_block)
+ def get_blob(_container_name, _blob_name, _options = {}, &block)
Fog::Logger.debug 'get_blob successfully.'
unless block_given?
return [
{
'name' => 'test_blob',
@@ -120,10 +120,10 @@
end
data = StringIO.new('content')
remaining = total_bytes = data.length
while remaining > 0
chunk = data.read([remaining, 2].min)
- Proc.new.call(chunk, remaining, total_bytes)
+ block.call(chunk, remaining, total_bytes)
remaining -= 2
end
[
{