Skip to content

Commit

Permalink
Replaced StreamReader.Peek()
Browse files Browse the repository at this point in the history
Replaced Peek() function because of issue that occurs only in .net6.0 dotnet/runtime#68983 when downloading large object (e.g. 8000+ child objects)
  • Loading branch information
Ferdi Meijer committed Jul 5, 2022
1 parent 0b972a1 commit 720e643
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Core/Core/Transports/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -479,15 +479,15 @@ private async Task<bool> CopyObjects(List<string> hashes, ITransport targetTrans
{
using (var reader = new StreamReader(stream, Encoding.UTF8))
{
while (reader.Peek() > 0)
string line;
while ((line = reader.ReadLine()) != null)
{
if (CancellationToken.IsCancellationRequested)
{
Queue = new ConcurrentQueue<(string, string, int)>();
return false;
}

var line = reader.ReadLine();
var pcs = line.Split(new char[] { '\t' }, count: 2);
targetTransport.SaveObject(pcs[0], pcs[1]);

Expand Down
5 changes: 2 additions & 3 deletions Core/Core/Transports/ServerUtils/ServerAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,14 @@ private async Task DownloadObjectsImpl(string streamId, List<string> objectIds,
{
using (var reader = new StreamReader(childrenStream, Encoding.UTF8))
{
while (reader.Peek() > 0)
string line;
while ((line = reader.ReadLine()) != null)
{
if (CancellationToken.IsCancellationRequested)
return;

var line = reader.ReadLine();
var pcs = line.Split(new char[] { '\t' }, count: 2);
onObjectCallback(pcs[0], pcs[1]);

}
}
}
Expand Down

0 comments on commit 720e643

Please sign in to comment.