Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Enumerable
  • Loading branch information
jalauzon-msft committed Nov 15, 2024
commit 423cb35c03c269c984529db573aca94ca06c18d6
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Threading;
using Azure.Core;
using Azure.Storage.Common;
using System.Linq;

namespace Azure.Storage.DataMovement
{
Expand Down Expand Up @@ -218,9 +219,9 @@ public override async Task ProcessPartToChunkAsync()
internal async Task UnknownDownloadInternal()
{
Task<StorageResourceReadStreamResult> initialTask = _sourceResource.ReadStreamAsync(
position: 0,
length: _initialTransferSize,
_cancellationToken);
position: 0,
length: _initialTransferSize,
_cancellationToken);

try
{
Expand Down Expand Up @@ -325,7 +326,7 @@ internal async Task LengthKnownDownloadInternal()
private async Task QueueChunksToChannel(long initialLength, long totalLength)
{
// Get list of ranges of the blob
IList<HttpRange> ranges = GetRangesList(initialLength, totalLength, _transferChunkSize);
IList<HttpRange> ranges = GetRanges(initialLength, totalLength, _transferChunkSize).ToList();

// Create Download Chunk event handler to manage when the ranges finish downloading
_downloadChunkHandler = GetDownloadChunkHandler(
Expand Down Expand Up @@ -467,14 +468,12 @@ private Task QueueCompleteFileDownload()
return QueueChunkToChannelAsync(CompleteFileDownload);
}

private static IList<HttpRange> GetRangesList(long initialLength, long totalLength, long rangeSize)
private static IEnumerable<HttpRange> GetRanges(long initialLength, long totalLength, long rangeSize)
{
IList<HttpRange> list = new List<HttpRange>();
for (long offset = initialLength; offset < totalLength; offset += rangeSize)
{
list.Add(new HttpRange(offset, Math.Min(totalLength - offset, rangeSize)));
yield return new HttpRange(offset, Math.Min(totalLength - offset, rangeSize));
}
return list;
}
#endregion PartitionedDownloader

Expand Down