private List<UploadedBlock> UploadDelta(string localFilePath, SignatureSearchResult searchResults, string containerName, string blobName, bool testMode = false, int parallelFactor=2)
{
var allUploadedBlocks = new List<UploadedBlock>();
// loop through each section of the search results.
// create blob from each RemainingBytes instances.
// reuse the blocks already in use.
foreach (var remainingBytes in searchResults.ByteRangesToUpload)
{
var uploadedBlockList = UploadBytesParallel(remainingBytes, localFilePath, containerName, blobName, testMode, parallelFactor);
allUploadedBlocks.AddRange(uploadedBlockList);
}
// once we're here we should have uploaded ALL new data to Azure Blob Storage.
// We then need to send the "construct" blob message.
// loop through existing blocks and get offset + blockId's.
foreach (var sig in searchResults.SignaturesToReuse)
{
if (sig.MD5Signature != null)
{
var blockId = Convert.ToBase64String(sig.MD5Signature);
allUploadedBlocks.Add(new UploadedBlock() { BlockId = blockId, Offset = sig.Offset, Size = sig.Size, Sig = sig, IsNew = false });
}
}
if (!testMode)
{
// needs to be sorted by offset so the final blob constructed is in correct order.
var res = (from b in allUploadedBlocks orderby b.Offset ascending select b.BlockId);
PutBlockList(res.ToArray(), containerName, blobName);
}
return allUploadedBlocks;
}