[TRUEZIP-333] Adding file to zip doesn't work if in the zip park there is symbolic link. Created: 18/Oct/13  Updated: 07/Feb/15  Resolved: 17/Nov/14

Status: Closed
Project: TrueZIP
Component/s: TrueZIP Driver ZIP
Affects Version/s: TrueZIP 7.6.6, TrueZIP 7.7.4
Fix Version/s: None

Type: Bug Priority: Major
Reporter: pskierczynski Assignee: Christian Schlichtherle
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Linux, Debian Wheezy 64bit, ext4 fs, Oracle JDK 1.7.0_45, Oracle JDK 1.6.0_45


I'll can workaround this, but I really think that it should be resolved in the library.

To reproduce:
1) create zip file in symlinked directory
2) create directory in zip
3) try to create file in directory (in zip)

Test that fails:
public void testAddingZipFilesInSymlinkedDirectory() throws Exception
final String OS = System.getProperty("os.name").toLowerCase();
final boolean isWindows = (OS.contains("win"));

if (!isWindows)
final File originalDirectory = Files.createTempDir();
final File placeForSymlink = Files.createTempDir();

final String symlinkPath = placeForSymlink.getAbsolutePath();


{ //create symlink instead of directory placeForSymlink.delete(); Runtime.getRuntime().exec(String.format("/bin/ln -s %s %s", originalDirectory.getAbsolutePath(), symlinkPath)); //zip will be in symlink final String zipArchivePath = placeForSymlink + File.separator + "test.zip"; final TFile zipArchive = new TFile(zipArchivePath); zipArchive.mkdirs(); //some directory in zip final TFile innerDirectory = new TFile(zipArchive, "someDir"); innerDirectory.mkdirs(); //and finally try to create file in directory final TFile innerFile = new TFile(innerDirectory, "someFile"); TFileOutputStream fos = new TFileOutputStream(innerFile); }


{ //trying to clean up after Runtime.getRuntime().exec(String.format("rm %s", symlinkPath)); Runtime.getRuntime().exec(String.format("rm -rf %s", originalDirectory.getAbsolutePath())); }


Comment by Christian Schlichtherle [ 17/Nov/14 ]

Your test runs fine on OS X 10.10 with Oracle JDK 1.7.0_72 and 1.8.0_25. I suppose to update your JDK version. I know that older versions had issues in their I/O implementation.

Generated at Thu Mar 23 22:35:16 UTC 2017 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.