mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-04-05 21:51:09 +00:00
AbstractReader.Skip doesn't work for UsePostDataDescriptor zip streams #115
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 @AlexVallat on GitHub (Aug 12, 2016).
Originally assigned to: @adamhathcock on GitHub.
In
AbstractReader.Skip()the shortcut to skip data by reading the raw stream rather than decompressing doesn't work if.CompressedSizeis 0 due to a UsePostDataDescriptor formatted zip entry header.@adamhathcock commented on GitHub (Aug 12, 2016):
It might be related to the thing you just fixed but that was me skipping data start position.
Anyway, if the descriptor doesn't put in a compressed size I don't know how I can just skip it without decompressing.
It's possible to scan the bytes for a zip header but that doesn't feel correct anyway. Already had issues with nested archives.
@AlexVallat commented on GitHub (Aug 12, 2016):
I don't think you can skip it without decompressing, if the size isn't known. The problem is that it should not skip 0 bytes and assume it's skipped the contents, I think it has to use the fallback path of actually reading the contents (like it does for the
Entry.IsSolidcase).@adamhathcock commented on GitHub (Aug 12, 2016):
OHH...I see. It thinks it should just skip 0 bytes. Yeah, you're right it should decompress it.
Any chance of a PR for this issue?
@AlexVallat commented on GitHub (Aug 12, 2016):
Simplest solution I can think of is to add to the
ZipEntryconstructor:but that might be abusing the IsSolid property? I only saw it set for Rars, and only consumed in the Skip() method so this would probably be OK, but it smells a bit. Could rename the property to
DecompressDuringSkipor similar, or otherwise I think it's going to take some extra plumbing.Or alternatively you could assume that if
CompressedSizewas 0 it should use a decompressed skip - probably harmless as if it really is empty it won't take long to decompress it!@adamhathcock commented on GitHub (Aug 12, 2016):
I guess where IsSolid is being checked should also check for the flag header and a size of zero to trigger the decompression
@AlexVallat commented on GitHub (Aug 12, 2016):
Unfortunately that's in AbstractReader, and therefore doesn't have access to the ZipEntry Header - it shouldn't, in principle, have knowledge of zip-specific flags.