diff --git a/Core/Core/Transports/Server.cs b/Core/Core/Transports/Server.cs index db2cb840ae..42a0d5a85b 100644 --- a/Core/Core/Transports/Server.cs +++ b/Core/Core/Transports/Server.cs @@ -479,7 +479,8 @@ private async Task CopyObjects(List 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) { @@ -487,7 +488,6 @@ private async Task CopyObjects(List hashes, ITransport targetTrans return false; } - var line = reader.ReadLine(); var pcs = line.Split(new char[] { '\t' }, count: 2); targetTransport.SaveObject(pcs[0], pcs[1]); diff --git a/Core/Core/Transports/ServerUtils/ServerAPI.cs b/Core/Core/Transports/ServerUtils/ServerAPI.cs index 6ffdad5962..61f6c52997 100644 --- a/Core/Core/Transports/ServerUtils/ServerAPI.cs +++ b/Core/Core/Transports/ServerUtils/ServerAPI.cs @@ -139,15 +139,14 @@ private async Task DownloadObjectsImpl(string streamId, List 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]); - } } }