althonos / fs.archive

Pyfilesystem2 for various archive filesystems

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TarReadFS errors when parsing a file created with dotslash paths

mattalxndr opened this issue · comments

If I create an archive like this:

touch file1
mkdir sub
touch sub/file2
tar cf test.tar ./file ./sub

then these don't work:

tarfs.exists('file1')
"""
Failure
Traceback (most recent call last):
  File "/[snip]/fs.archive/tests/test_tarfs.py", line 202, in test_exists
    self.assertTrue(self.tarfs.exists('file1'))
AssertionError: False is not true
"""

self.tarfs.walk.info()
"""
Error
Traceback (most recent call last):
  File "/[snip]/fs.archive/.venv/lib/python3.10/site-packages/fs/archive/tarfs/__init__.py", line 131, in getinfo
    tar_info = self._members[_path]
KeyError: 'file1'
"""


self.tarfs.listdir('/')
"""
Error
Traceback (most recent call last):
  File "/[snip]/fs.archive/.venv/lib/python3.10/site-packages/fs/archive/tarfs/__init__.py", line 131, in getinfo
    tar_info = self._members[_path]
KeyError: 'sub'
"""

I know this bug report is incomplete, but I have a pull request to fix it, which I'm pushing now.

Hi Matt, thanks for catching that!