MarketSquare / robotframework-archivelibrary

https://github.com/MarketSquare/robotframework-archivelibrary
22 stars 24 forks source link

Zip file with directory structure #12

Closed aaltat closed 9 years ago

aaltat commented 9 years ago

Ugh

If I have zip file which has subfolders and files in it. In some cases the ArchiveLibrary is not able to extract the zip file correctly. This seems be related that if I do this:

zf = zipfile.ZipFile(zfile)
print zf.namelist()

It will only print the files. Example:

['path1/file1.txt', 'path1/file2.txt', ...] 

The archive library seems to expect that also paths are also included in the zf.namelist(). Example:

['path1', 'path1/file1.txt', 'path1/file2.txt', ...] 

But one create zip file with -no-dir-entries [1] flag in Linux and then the print zf.namelist() will only list the paths to files and zip file does not contain directory entries. Then the ArchiveLibrary fill fail on this stack trace:

DEBUG   Traceback (most recent call last): File "C:\Python27\lib\site-packages\ArchiveLibrary\keywords.py", line 43, in extract_zip_file unzipper.extract(zfile, dest) File "C:\Python27\lib\site-packages\ArchiveLibrary\utils.py", line 41, in extract outfile = open(os.path.join(dest, name), 'wb'

[1]http://linux.die.net/man/1/zip

bulkan commented 9 years ago

Pull requests welcome. :+1:

aaltat commented 9 years ago

Could do that. There is question though: By looking the code and looking the python ZipFile documentation, is there are reason why the ZipFile.extractall() function is not used to extract the archive?

bulkan commented 9 years ago

There probably was a reason but its been so long that I dont remember

aaltat commented 9 years ago

If the acceptance tests pass, would you accept a pull request that would change to code to use the ZipFile.extractall()? Or would you more willing to see fix based on the existing implementation?

bulkan commented 9 years ago

I sure will accept a PR if the tests pass.

aaltat commented 9 years ago

When trying to looking the issue with fresh eyes, I can not reproduce the issue. Closing.