Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

seekstart/seek/seekend leads to invalid position #109

Closed
Marlin-Na opened this issue Jul 4, 2021 · 0 comments · Fixed by #227 or #229
Closed

seekstart/seek/seekend leads to invalid position #109

Marlin-Na opened this issue Jul 4, 2021 · 0 comments · Fixed by #227 or #229
Labels

Comments

@Marlin-Na
Copy link

Marlin-Na commented Jul 4, 2021

Currently TranscodingStreams has default methods for seekstart seekend and position. position implementation is based on the bytes read from the io. However, when seekstart or seekend is called, it will lead to invalid position. For example:

# Create a gzip file
using CodecZlib
s = GzipCompressorStream(open("/tmp/test.txt.gz", "w"))
write(s, "abbccc"); close(s)

# Reading stream
s = GzipDecompressorStream(open("/tmp/test.txt.gz"))
read(s, Char); position(s) ## position is 1, correct!
seekstart(s); position(s)  ## position changes to 6, it should be 0
read(s, Char); position(s) ## position changes to 7, it should be 1
seekend(s); position(s)    ## position changes to 12, it should be 6

I think when seekstart is called, we probably need to reset the Stats of the stream. For seekend, I think it might be hard/impossible to get the right position after decompression, however at least an warning should be given. seek is not provided by default, however if a Codec implements only seek but not position, it might leads invalid position as well.

What's your thoughts on this issue? Maybe it is possible to just issue an warning when calling position after called seek/seekstart/seekend? Then a Codec might implements its specialized methods for position (e.g. for Noop).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants