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

Preserve file permissions #52

Closed
latuszek opened this issue May 26, 2014 · 13 comments
Closed

Preserve file permissions #52

latuszek opened this issue May 26, 2014 · 13 comments

Comments

@latuszek
Copy link

It would be nice if file permissions under Unix system could be preserved.

@shelajev
Copy link
Contributor

Hi @seiyapl, it would be nice inceed. However, it's not that easy to implement. Obvious Unix vs. Windows permissions incompatibility aside (which means that we won't be able to make it work for cross-platform use), Java is not that good at setting file permissions.

Storing the mask of a file into an extra field on a ZipEntry is easy, however, obtaining it from the file and then setting it for unzipped file is harder. Especially Zt-Zip being Java 4 compatible.

We'll look into it anyway, but if you have a good idea about how to do it, please mention it. Maybe you can come up with a pull-request that shows what do you have in mind?

@latuszek
Copy link
Author

Hi @shelajev. I know it won't be easy and I'm afraid I won't be helpful. I can only describe my use case. I'm using zt-zip in my autodeployment app which compress entire tomcat directory. However when I need to do rollback, file permissions are not restored. Currently I'm just changing them after unzipping calling unix "chmod" for all *.sh files.

@toomasr
Copy link
Collaborator

toomasr commented May 27, 2014

I'm not too pessimistic about this as Ant actually supports the basics. I think delivering something similar will make a lot of users happy.

@nemecec
Copy link
Collaborator

nemecec commented May 27, 2014

Well, one possibility would be to include a class to handle that, using Java7 API. So zt-zip would use that, but only when running on Java7.

@toomasr
Copy link
Collaborator

toomasr commented May 27, 2014

@shelajev shelajev self-assigned this May 30, 2014
@shelajev
Copy link
Contributor

I'm taking this for myself. I'm looking into making it work on POSIX systems with modern enough Java version.

@seiyapl what version of Java do you use? I'll target that first and then we'll think how to improve the generic support later.

@latuszek
Copy link
Author

@shelajev Here's my current version:

java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

However, I think we will update to 1.7.0_60 soon.

@toomasr
Copy link
Collaborator

toomasr commented Jun 2, 2014

@shelajev be sure not to invent the wheel. The Unix and DOS permissions are in the external fields ( http://www.pkware.com/documents/casestudies/APPNOTE.TXT ) and there is an implementation at http://svn.apache.org/repos/asf/ant/core/tags/ANT_170/src/main/org/apache/tools/zip/ZipEntry.java

@shelajev
Copy link
Contributor

I've put some time into investigating this. There's no easy solution in fact. Even with the Ant code at hand. The jdk's ZipOutputStream writes 0 for the external ettributes field of every entry. And it doesn't make it easy to extends the code.

Ant has their own ZipEntry implementation that has a field for the external attributes and their own ZipOutputStream to write the attributes to the correct place.

Just wanted to mention that I looked into that. Don't know how do we want to proceed yet.

@toomasr
Copy link
Collaborator

toomasr commented Jul 14, 2014

Why not take similar approach?

@shelajev
Copy link
Contributor

Hm, indeed. I'll prepare a branch, we can look at how the code looks and decide then.

reinra pushed a commit that referenced this issue Aug 27, 2014
@shelajev shelajev removed their assignment Aug 27, 2014
@shelajev
Copy link
Contributor

shelajev commented Sep 8, 2014

Thanks, Viktor!

we need more tests for the permissions functionality, but the feature is implemented and all interested parties can try / test / use it.

@shelajev shelajev closed this as completed Sep 8, 2014
@hamzasAnwar
Copy link

hamzasAnwar commented Feb 1, 2019

Hi, what is the status of this ? is it preserving unix permissions even if i extract it on windows?
as i am looking for something which takes a zip file and remove some entries and recreates the zip file without loosing the unix permissions?

any help would be very appreciated.

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

5 participants