Check is stream is disposed before reading position.

This commit is contained in:
Michael Bucari-Tovo
2025-11-25 12:28:47 -07:00
parent af85ea9219
commit d8104a4d7c

View File

@@ -26,7 +26,17 @@ namespace AaxDecrypter
protected string OutputDirectory { get; }
public IDownloadOptions DownloadOptions { get; }
protected NetworkFileStream InputFileStream => NfsPersister.NetworkFileStream;
protected virtual long InputFilePosition => InputFileStream.Position;
protected virtual long InputFilePosition
{
get
{
//Use try/catch instread of checking CanRead to avoid
//a race with the background download completing
//between the check and the Position call.
try { return InputFileStream.Position; }
catch { return InputFileStream.Length; }
}
}
private bool downloadFinished;
private NetworkFileStreamPersister? m_nfsPersister;