Skip to content

Commit

Permalink
more logic fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Hathcock committed Apr 11, 2024
1 parent cb22321 commit 373637e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/SharpCompress/Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,12 @@ public static long TransferTo(this Stream source, Stream destination)
public static long TransferTo(this Stream source, Stream destination, long maxLength)
{
var array = GetTransferByteArray();
var maxReadSize = array.Length;
try
{
long total = 0;
var remaining = maxLength;
var maxReadSize = array.Length;
if (remaining < maxLength)
if (remaining < maxReadSize)
{
maxReadSize = (int)remaining;
}
Expand All @@ -309,6 +309,10 @@ public static long TransferTo(this Stream source, Stream destination, long maxLe
break;
}
remaining -= count;
if (remaining < maxReadSize)
{
maxReadSize = (int)remaining;
}
}
return total;
}
Expand Down

0 comments on commit 373637e

Please sign in to comment.