Skip to content

Commit 65347bc

Browse files
Merge pull request #5 from zontal/try_to_close_stream
ZSPACE-12730 Try to close the underlying stream.
2 parents 793055f + 5b653df commit 65347bc

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
@@ -617,8 +617,16 @@ public override void Write(IRawDataPlus rawFile, int firstScanNumber, int lastSc
617617

618618
if (_doIndexing)
619619
{
620-
cryptoStream.Flush();
621-
cryptoStream.Close();
620+
try
621+
{
622+
cryptoStream.Flush();
623+
cryptoStream.Close();
624+
}
625+
catch (System.ObjectDisposedException e)
626+
{
627+
// Cannot access a closed file. CryptoStream was already closed when closing _writer
628+
Log.Warn($"Warning: {e.Message}");
629+
}
622630
}
623631
}
624632

0 commit comments

Comments
 (0)