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

Exception when appending a directory to existing archive #505

Open
erdalkaraca opened this issue Jan 24, 2023 · 1 comment
Open

Exception when appending a directory to existing archive #505

erdalkaraca opened this issue Jan 24, 2023 · 1 comment

Comments

@erdalkaraca
Copy link

erdalkaraca commented Jan 24, 2023

When opening an archive to append a directory (recursively) an exception is raised:

Traceback (most recent call last):
  [...]
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\py7zr\py7zr.py", line 410, in __exit__
    self.close()
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\py7zr\py7zr.py", line 1077, in close
    self._write_flush()
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\py7zr\py7zr.py", line 685, in _write_flush
    self._write_header()
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\py7zr\py7zr.py", line 693, in _write_header
    encrypted=self.header_encryption,
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\py7zr\archiveinfo.py", line 1004, in write
    startpos, headercrc = self._encode_header(file, afterheader, filters)
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\py7zr\archiveinfo.py", line 971, in _encode_header
    _, raw_header_len, raw_crc = self.write(buf, 0, False)
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\py7zr\archiveinfo.py", line 1009, in write
    self.main_streams.write(crcfile)
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\py7zr\archiveinfo.py", line 664, in write
    self.substreamsinfo.write(file)
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\py7zr\archiveinfo.py", line 616, in write
    write_uint64(file, self.unpacksizes[idx])
IndexError: list index out of range

I am not sure, but a fix seems to be the following modification in archiveinfo.py:

image

Fix: indent the idx += 1 into the if clause.

before:
image

If this fix sounds reasonable, I can create a PR.

@miurahr
Copy link
Owner

miurahr commented Jan 25, 2023

A pull-request is always welcome. It is great if you add a test case for regression test.

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