@@ -251,4 +251,58 @@ await reader.WriteEntryToDirectoryAsync(
251251 }
252252 Assert . Equal ( 8 , count ) ;
253253 }
254+
255+ [ Fact ]
256+ public async ValueTask EntryStream_Dispose_DoesNotThrow_OnNonSeekableStream_Deflate_Async ( )
257+ {
258+ // Since version 0.41.0: EntryStream.DisposeAsync() should not throw NotSupportedException
259+ // when FlushAsync() fails on non-seekable streams (Deflate compression)
260+ var path = Path . Combine ( TEST_ARCHIVES_PATH , "Zip.deflate.dd.zip" ) ;
261+ using Stream stream = new ForwardOnlyStream ( File . OpenRead ( path ) ) ;
262+ using var reader = ReaderFactory . Open ( stream ) ;
263+
264+ // This should not throw, even if internal FlushAsync() fails
265+ while ( await reader . MoveToNextEntryAsync ( ) )
266+ {
267+ if ( ! reader . Entry . IsDirectory )
268+ {
269+ #if LEGACY_DOTNET
270+ using var entryStream = await reader . OpenEntryStreamAsync ( ) ;
271+ #else
272+ await using var entryStream = await reader . OpenEntryStreamAsync ( ) ;
273+ #endif
274+ // Read some data
275+ var buffer = new byte [ 1024 ] ;
276+ await entryStream . ReadAsync ( buffer , 0 , buffer . Length ) ;
277+ // DisposeAsync should not throw NotSupportedException
278+ }
279+ }
280+ }
281+
282+ [ Fact ]
283+ public async ValueTask EntryStream_Dispose_DoesNotThrow_OnNonSeekableStream_LZMA_Async ( )
284+ {
285+ // Since version 0.41.0: EntryStream.DisposeAsync() should not throw NotSupportedException
286+ // when FlushAsync() fails on non-seekable streams (LZMA compression)
287+ var path = Path . Combine ( TEST_ARCHIVES_PATH , "Zip.lzma.dd.zip" ) ;
288+ using Stream stream = new ForwardOnlyStream ( File . OpenRead ( path ) ) ;
289+ using var reader = ReaderFactory . Open ( stream ) ;
290+
291+ // This should not throw, even if internal FlushAsync() fails
292+ while ( await reader . MoveToNextEntryAsync ( ) )
293+ {
294+ if ( ! reader . Entry . IsDirectory )
295+ {
296+ #if LEGACY_DOTNET
297+ using var entryStream = await reader . OpenEntryStreamAsync ( ) ;
298+ #else
299+ await using var entryStream = await reader . OpenEntryStreamAsync ( ) ;
300+ #endif
301+ // Read some data
302+ var buffer = new byte [ 1024 ] ;
303+ await entryStream . ReadAsync ( buffer , 0 , buffer . Length ) ;
304+ // DisposeAsync should not throw NotSupportedException
305+ }
306+ }
307+ }
254308}
0 commit comments