Skip to content
Merged
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ public static async Task<bool> IsFileIdenticalToBlobAsync(this BlobClient client
return blobMD5.Equals(localMD5, StringComparison.OrdinalIgnoreCase);
}

var localFileSize = new FileInfo(file).Length;
var blobSize = (await client.GetPropertiesAsync()).Value.ContentLength;

if (localFileSize != blobSize)
{
return false;
}

int bytesPerMegabyte = 1 * 1024 * 1024;
using Stream localFileStream = File.OpenRead(file);
byte[] localBuffer = new byte[bytesPerMegabyte];
Expand All @@ -42,6 +50,11 @@ public static async Task<bool> IsFileIdenticalToBlobAsync(this BlobClient client
{
long start = localFileStream.Position;
localBytesRead = await localFileStream.ReadAsync(localBuffer, 0, bytesPerMegabyte);
if (localBytesRead == 0)
{
// eof == we are done, we have already validated that they are the same size
return true;
}

var range = new HttpRange(start, localBytesRead);
BlobDownloadInfo download = await client.DownloadAsync(range).ConfigureAwait(false);
Expand Down