Merge pull request #756 from wabbajack-tools/less-rapid-hashing-messages

Update the UI less often while hashing files
This commit is contained in:
Timothy Baldridge 2020-04-26 22:58:30 -06:00 committed by GitHub
commit 69cca90a56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 6 deletions

View File

@ -316,7 +316,7 @@ namespace Compression.BSA
{
if (Compressed)
{
var r = LZ4Stream.Decode(rdr.BaseStream);
using var r = LZ4Stream.Decode(rdr.BaseStream);
r.CopyToLimit(output, (int) _originalSize);
}
else
@ -327,10 +327,10 @@ namespace Compression.BSA
else
{
if (Compressed)
using (var z = new InflaterInputStream(rdr.BaseStream))
{
z.CopyToLimit(output, (int) _originalSize);
}
{
using var z = new InflaterInputStream(rdr.BaseStream);
z.CopyToLimit(output, (int) _originalSize);
}
else
rdr.BaseStream.CopyToLimit(output, (int) _onDiskSize);
}

View File

@ -1,4 +1,5 @@
using System.IO;
using System;
using System.IO;
namespace Wabbajack.Common
{
@ -7,12 +8,14 @@ namespace Wabbajack.Common
private string _message;
private Stream _inner;
private WorkQueue? _queue;
private DateTime _lastUpdate;
public StatusFileStream(Stream fs, string message, WorkQueue? queue = null)
{
_queue = queue;
_inner = fs;
_message = message;
_lastUpdate = DateTime.UnixEpoch;
}
public override void Flush()
@ -38,6 +41,13 @@ namespace Wabbajack.Common
private void UpdateStatus()
{
if (DateTime.Now - _lastUpdate < TimeSpan.FromMilliseconds(500))
{
return;
}
_lastUpdate = DateTime.Now;
if (_inner.Length == 0)
{
return;