sanity checks

This commit is contained in:
13xforever 2019-03-16 18:58:12 +05:00
parent 14f317ffdc
commit 8794d29976
2 changed files with 7 additions and 1 deletions

View File

@ -15,6 +15,12 @@ namespace CompatBot.Utils
public BufferCopyStream(Stream baseStream, int bufferSize = 4096)
{
if (baseStream == null)
throw new ArgumentNullException(nameof(baseStream));
if (bufferSize < 1)
throw new ArgumentException("Buffer size cannot be non-positive", nameof(bufferSize));
this.baseStream = baseStream;
bufSize = bufferSize;
buf = new byte[bufSize];

View File

@ -471,7 +471,7 @@ namespace CompatBot.Utils.ResultFormatters
else
msg = $"Log from {member.DisplayName.Sanitize()} | {member.Id}\n";
msg += " | " + (source?.SourceType ?? "Unknown source");
if (state?.ReadBytes > 0 && source?.LogFileSize > 0)
if (state?.ReadBytes > 0 && source?.LogFileSize > 0 && source.LogFileSize < 2L*1024*1024*1024)
msg += $" | Parsed {state.ReadBytes * 100.0 / source.LogFileSize:0.##}%";
else if (source?.SourceFilePosition > 0 && source.SourceFileSize > 0)
msg += $" | Read {source.SourceFilePosition * 100.0 / source.SourceFileSize:0.##}%";