Skip to content

Commit 01c6a2f

Browse files
committed
Query underlying Stream object for Length, but fallback to original mechanism if the stream doesn't support the Length operation. Addresses drewnoakes#122 by allowing for streamed parsing of metadata.
1 parent 3e3a3ba commit 01c6a2f

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

MetadataExtractor/IO/IndexedCapturingReader.cs

+10-3
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,16 @@ public override long Length
6060
{
6161
get
6262
{
63-
IsValidIndex(int.MaxValue, 1);
64-
Debug.Assert(_isStreamFinished);
65-
return _streamLength;
63+
try
64+
{
65+
return _stream.Length;
66+
}
67+
catch (NotSupportedException)
68+
{
69+
IsValidIndex(int.MaxValue, 1);
70+
Debug.Assert(_isStreamFinished);
71+
return _streamLength;
72+
}
6673
}
6774
}
6875

0 commit comments

Comments
 (0)