Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Commit

Permalink
PR review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
KrzysztofCwalina committed Mar 23, 2018
1 parent 40bec88 commit 474d53f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static async Task WriteAsync(this PipeWriter writer, Stream stream, long
while (bytesToWrite > 0)
{
Memory<byte> buffer = writer.GetMemory();
if(buffer.Length > bytesToWrite)
if (buffer.Length > bytesToWrite)
{
buffer = buffer.Slice(0, (int)bytesToWrite);
}
Expand Down
4 changes: 2 additions & 2 deletions samples/AzCopyCore/AzCopyCore/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ static async ValueTask<bool> CopyLocalFileToStorageFile(StorageClient client, st
long bytesLeft = bytes.Length;
long index = 0;
int length = 1024 * 1024 * 4;
while (true)
while (bytesLeft > 0)
{
if (bytesLeft < length) length = (int)bytesLeft;
var putRequest = new PutRangeRequest(storagePath, bytes, index, length);
Expand All @@ -212,7 +212,7 @@ static async ValueTask<bool> CopyLocalFileToStorageFile(StorageClient client, st
}
index += length;
bytesLeft -= length;
if (bytesLeft == 0) break;
Debug.Assert(bytesLeft >= 0);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions samples/AzCopyCore/AzCopyCore/StorageRequests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public struct PutRangeRequest : IStorageRequest

public PutRangeRequest(string filePath, Stream fileContent, long offset, int length)
{
if (offset < 0) throw new ArgumentOutOfRangeException(nameof(offset));
if (offset < 0 || offset > fileContent.Length - length) throw new ArgumentOutOfRangeException(nameof(offset));
if (length < 1) throw new ArgumentOutOfRangeException(nameof(length));

_filePath = filePath;
Expand All @@ -139,7 +139,7 @@ class Writer : StorageRequestWriter<PutRangeRequest>

protected override async Task WriteBody(PipeWriter writer, PutRangeRequest arguments)
{
var stream = arguments._fileContent;
Stream stream = arguments._fileContent;
stream.Seek(arguments._offset, SeekOrigin.Begin);
await writer.WriteAsync(stream, arguments._length);
}
Expand All @@ -150,8 +150,8 @@ protected override void WriteXmsHeaders(ref BufferWriter writer, ref PutRangeReq
writer.WriteHeader("x-ms-date", Time, 'R');
// TODO (pri 3): this allocation should be eliminated

var start = arguments._offset;
var end = start + arguments._length - 1;
long start = arguments._offset;
long end = start + arguments._length - 1;
writer.WriteHeader("x-ms-range", $"bytes={start}-{end}");
writer.WriteHeader("x-ms-version", "2017-04-17");
writer.WriteHeader("x-ms-write", "update");
Expand Down

0 comments on commit 474d53f

Please sign in to comment.