mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-03 21:23:38 +00:00
Iterating TarArchive.Entries fails if EntryStream.CopyToAsync called #77
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @matthewDDennis on GitHub (Jan 18, 2016).
The following code fails if the
archive.Entries.ToList()is changed toarchive.Entries. I suspect that there is interaction with the streams. So callingToList()prevents this as the Enumeration of the Entries will complete its use of the stream.@matthewDDennis commented on GitHub (Jan 18, 2016):
A quick look at the code shows that
TarArchive.Entriesis usingyield. Thus, it will allow theStreamto be repositioned between eachEntrycausing the reading of the headers to fail due to the position change.@adamhathcock commented on GitHub (Jan 19, 2016):
Is this only an issue if you use CopyToAsync? I haven't looked at the code just yet but your statement seems to imply that.
I hope not. Otherwise, the bug might be more serious :)
@iamcarbon commented on GitHub (Jun 22, 2017):
Ran into this as well. Creating an array form the entries before enumerating solved the problem.
@Eli-Black-Work commented on GitHub (Sep 6, 2019):
I'm seeing this as well, but after calling OpenEntryStream().ReadAsync() on an entry while iterating through TarArchive.Entries
iamcarbon's fix worked; thanks :)