Fixed rare bug that would cause a hang if an error occured in the download loop
This commit is contained in:
parent
2c42b4c585
commit
cfd2b7b7aa
@ -5,7 +5,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AAXClean.Codecs" Version="0.2.9" />
|
<PackageReference Include="AAXClean.Codecs" Version="0.2.10" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -145,7 +145,14 @@ namespace AaxDecrypter
|
|||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
RequestHeaders = HttpRequest.Headers;
|
RequestHeaders = HttpRequest.Headers;
|
||||||
Updated?.Invoke(this, EventArgs.Empty);
|
try
|
||||||
|
{
|
||||||
|
Updated?.Invoke(this, EventArgs.Empty);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Serilog.Log.Error(ex, "An error was encountered while saving the download progress to JSON");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -245,9 +252,6 @@ namespace AaxDecrypter
|
|||||||
WritePosition = downloadPosition;
|
WritePosition = downloadPosition;
|
||||||
Update();
|
Update();
|
||||||
|
|
||||||
downloadedPiece.Set();
|
|
||||||
downloadEnded.Set();
|
|
||||||
|
|
||||||
if (!IsCancelled && WritePosition < ContentLength)
|
if (!IsCancelled && WritePosition < ContentLength)
|
||||||
throw new WebException($"Downloaded size (0x{WritePosition:X10}) is less than {nameof(ContentLength)} (0x{ContentLength:X10}).");
|
throw new WebException($"Downloaded size (0x{WritePosition:X10}) is less than {nameof(ContentLength)} (0x{ContentLength:X10}).");
|
||||||
|
|
||||||
@ -259,6 +263,11 @@ namespace AaxDecrypter
|
|||||||
Serilog.Log.Error(ex, "An error was encountered while downloading {Uri}", Uri);
|
Serilog.Log.Error(ex, "An error was encountered while downloading {Uri}", Uri);
|
||||||
IsCancelled = true;
|
IsCancelled = true;
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
downloadedPiece.Set();
|
||||||
|
downloadEnded.Set();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -401,10 +410,11 @@ namespace AaxDecrypter
|
|||||||
{
|
{
|
||||||
if (!hasBegunDownloading)
|
if (!hasBegunDownloading)
|
||||||
BeginDownloading();
|
BeginDownloading();
|
||||||
|
|
||||||
var toRead = Math.Min(count, Length - Position);
|
var toRead = Math.Min(count, Length - Position);
|
||||||
WaitToPosition(Position + toRead);
|
WaitToPosition(Position + toRead);
|
||||||
return _readFile.Read(buffer, offset, count);
|
|
||||||
|
return IsCancelled ? 0 : _readFile.Read(buffer, offset, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override long Seek(long offset, SeekOrigin origin)
|
public override long Seek(long offset, SeekOrigin origin)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user