-
Notifications
You must be signed in to change notification settings - Fork 309
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
addFolder issue #169
Comments
I just tried to add a folder which contains empty folders inside it, and it had the empty folders in the generated zip file. And even the empty folder was created when extracting the same zip file again with zip4j. It could be that the tool which shows/extracts the zip file in your case, ignore empty directories. Can you attach a sample zip file generated by zip4j which was supposed to have empty folders in it? |
If I understand the issue right from the screenshot, zip4j missed to add some directories, for example "matrices", "sdfsdfsd", etc, right? Does these directories have any content inside them like other directories or files? Was the zip file already existing before your code executed? I was still not able to reproduce this with a similar directory structure as you. My guess is that the files api is not returning the directories that in the end zip4j missed to add. Can you please set a breakpoint at AddFilesToZipTask.getFilesToAdd() line 66 as shown in the image below, and let me know if you see the directories that are missed in the zip created by zip4j? Maybe you can also post a screenshot? |
From the previous example, folder matrices contain only empty folders. This is a list of the folder to archive :
Here's complete code for example:
This is the list of files from the brake point:
this is archive created by OS ( nautilus -> compress) and this is an archive created by the example program |
The zip file generated by zip4j This is the content after zip4j extracted that zip file. As you can see there were empty directories also extracted. Maybe the tool which you use to extract does not extract empty directories from a zip. Or maybe if you are just viewing the zip file, the tool does not show empty directories in its view. |
When you extract it with zip4j, are the empty directories extracted? |
And also, with the zip file generated by native OS tool, can you see those empty directories in Ubuntu archive manager? |
Hi, when I extract the archive, all folders are there, I'll check how it behaves on windows and let you know. |
Can you also answer this question please:
|
I have generated three test files for testing. Can you please post me the screenshots if the Ubuntu Archive manager is showing empty folders for any of these zip file? file_only_second_header.zip |
Can you please check again with this file if it shows empty folders? |
This one was created by Keka, and not by zip4j. There are not too many differences between the one created by zip4j and by Keka or ubuntu tool. Not sure why Archive manager decides to skip the ones created by zip4j. Looking into it. It might be that I will send you a few more files to check. |
Can you check these 3 zip files again please? |
I think now I figured out the issue. But I am quite surprised that the archive manager is behaving this way. Basically, zip4j uses utf8 as default charset. Archive manager seems to ignore the directories which are marked as utf8. Strangely it shows files which are utf8, but seems to ignore only the directories if they are utf8. Do you have utf8 charset support on your os? And also can you please post the screenshot for one more zip file attached below? |
This is a really strange behaviour by Archive Manager. This seems to be a bug in their tool. Zip specification allows using Cp-437 and utf-8 as standard charsets. And zip4j uses utf-8 as its default charset. Apparently, archive manager on Ubuntu seems to ignore directories which use utf-8 encoding but file names does not contain any non-ascii character. This is totally not against the zip specification, and utf-8 encoding can be used as long as the appropriate flag is set, which zip4j sets in this case. One way for zip4j would have been to use cp-437 by default and use utf-8 only when needed (in case of non-ascii characters), but I do not want to change the default behaviour of zip4j now for this bug in Archive manager, especially when such behaviour is not against zip specification. And moreover, the files and folders in the zip are properly extracted, and other tools do not have any problem with viewing and extracting, I will have to mark this as "not-an-issue". |
Thank You for Your time and effort. |
Hi, is there an option to include empty folders in archive. I'm trying to create backup archive for my folders, but empty folders are missing in created zip file.
The text was updated successfully, but these errors were encountered: