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

testzip() method is documented but does not exist #137

Closed
myers opened this issue Jun 1, 2020 · 5 comments
Closed

testzip() method is documented but does not exist #137

myers opened this issue Jun 1, 2020 · 5 comments
Assignees
Labels
bug Something isn't working documentation Issue on documentation

Comments

@myers
Copy link

myers commented Jun 1, 2020

Describe the bug
Documentation (https://py7zr.readthedocs.io/en/latest/py7zr.html#py7zr.SevenZipFile.testzip) says there is a testzip() method on SevenZipFile that returns the name of the first corrupt file or None. There isn't. There is a test() method that return True if the file is not corrupt or False if it is

To Reproduce
Steps to reproduce the behavior:
(example)

  1. Run following code with python3.
    '
    import py7zr
    archive = py7zr.SevenZipFile('test.7z','w')
    archive.testzip()
    '
  2. see error

Expected behavior
Either add the method (which I think would be a good idea as that is what the zipfile module does) or correct the docs.

Environment (please complete the following information):

  • OS: Ubuntu Linux 20.04
  • Python 3.8
  • py7zr version: 0.7.1
@miurahr
Copy link
Owner

miurahr commented Jun 1, 2020

It seems a document error. There is a test() method.

@miurahr miurahr added bug Something isn't working documentation Issue on documentation good first issue Good for newcomers labels Jun 1, 2020
@miurahr
Copy link
Owner

miurahr commented Jun 2, 2020

There is a point to discuss an API and behavior.
7-zip specification defines 2 digests.

  1. packinfo digests -- digest of compressed data, it can be checked w/o extracting. (optional)
  2. unpackinfo digests -- crc32 of uncompressed files. it is necessary to extract to check it. (exist in default)

py7zr try to check both in current implementation, check (1) first then check (2).

It may be able to split these two digests check to two methods, such as .test() for (1) and .testzip() for (2). There has already existed internal functions; _test_pack_digests() and _test_unpack_digests()

On ZIP archive, there are CRC32 of uncompressed files only, that is as same as unpack digest in 7zip.

@miurahr
Copy link
Owner

miurahr commented Jun 2, 2020

Now I found a current implementation does not actually not checking CRC32 of each file.
There is only a code for checking folder digest (optional field) and header crcs(that working).

@miurahr
Copy link
Owner

miurahr commented Jun 2, 2020

Now Pushed a fix for CRC32 checks. Introduce test() method for packed CRC32 and testzip() method for unpacked archives.

@myers
Copy link
Author

myers commented Jun 2, 2020

Awesome! Thank you!

@myers myers closed this as completed Jun 2, 2020
@miurahr miurahr added this to the v0.8: Encryption support milestone Jun 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Issue on documentation
Projects
None yet
Development

No branches or pull requests

2 participants