bluec0re / android-backup-tools

Unpack and repack android backups

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to read a file extract from tar given by read_data

rytilahti opened this issue · comments

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

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.

New constructor flag: stream

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

Thanks for the fix!