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

Unable to read a file extract from tar given by read_data #2

Closed
rytilahti opened this issue Oct 24, 2017 · 3 comments
Closed

Unable to read a file extract from tar given by read_data #2

rytilahti opened this issue Oct 24, 2017 · 3 comments

Comments

@rytilahti
Copy link

I just tried to change to use the version from pypi (see rytilahti/python-miio#101) and got hit by a seek()ing error. Any ideas if that comes from the use of proxying / internals of this package?

  File "/home/hass/home-assistant/libs/xiaomi-vacuum/miio/extract_tokens.py", line 127, in main
    db_contents = db.read()
  File "/home/hass/venv/lib/python3.5/tarfile.py", line 686, in read
    self.fileobj.seek(offset + (self.position - start))
  File "/home/hass/venv/lib/python3.5/tarfile.py", line 514, in seek
    raise StreamError("seeking backwards is not allowed")
tarfile.StreamError: seeking backwards is not allowed
@bluec0re
Copy link
Owner

It's part of the tarfile library if the underlying fileobject ist loaded as a stream:

https://docs.python.org/2/library/tarfile.html#tarfile.open

I've used this approach reduce the memory requirements if compression/encryption is used. Otherwise I would need to decompress/decrypt the whole backup file in memory. I'll add a constructor flag which enables this behavior and therefor can be selected depending on the usecase.

@bluec0re
Copy link
Owner

New constructor flag: stream

True -> use memory efficient streams (default)
False -> decompress/-crypt in memory

@rytilahti
Copy link
Author

Thanks for the fix!

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

No branches or pull requests

2 participants