Merge pull request #582 from NextTurn/filelen

Fix file length accumulation
pull/629/head
Oleg Nenashev 2020-08-05 11:32:11 +02:00 committed by GitHub
commit 0862d06905
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -4,6 +4,7 @@ using System.Diagnostics;
using System.IO.Compression;
#endif
using System.IO;
using System.Text;
using System.Threading;
#if !VNEXT
using ICSharpCode.SharpZipLib.Zip;
@ -264,7 +265,7 @@ namespace WinSW
string? line;
while ((line = reader.ReadLine()) != null)
{
int lengthToWrite = (line.Length + Environment.NewLine.Length) * sizeof(char);
int lengthToWrite = Encoding.UTF8.GetByteCount(line) + 2; // CRLF
if (fileLength + lengthToWrite > this.SizeTheshold)
{
writer.Dispose();
@ -437,7 +438,7 @@ namespace WinSW
{
lock (fileLock)
{
int lengthToWrite = (line.Length + Environment.NewLine.Length) * sizeof(char);
int lengthToWrite = Encoding.UTF8.GetByteCount(line) + 2; // CRLF
if (fileLength + lengthToWrite > this.SizeTheshold)
{
try