Skip to content

Commit 5b653df

Browse files
ZSPACE-12730 Try to close the underlying stream.
1 parent 45ed3df commit 5b653df

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Writer/MzMlSpectrumWriter.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,8 +587,16 @@ public override void Write(IRawDataPlus rawFile, int firstScanNumber, int lastSc
587587

588588
if (_doIndexing)
589589
{
590-
cryptoStream.Flush();
591-
cryptoStream.Close();
590+
try
591+
{
592+
cryptoStream.Flush();
593+
cryptoStream.Close();
594+
}
595+
catch (System.ObjectDisposedException e)
596+
{
597+
// Cannot access a closed file. CryptoStream was already closed when closing _writer
598+
Log.Warn($"Warning: {e.Message}");
599+
}
592600
}
593601
}
594602

0 commit comments

Comments
 (0)