I created one directory with a symlink to it and a regular file with a symlink to it like so:
$ mkdir tmp
$ cd tmp
$ mkdir a; ln -s a b; touch c; ln -s c d
$ cd ..
$ tree tmp
tmp
├── a
├── b -> a
├── c
└── d -> c
Ideally what would happen is the following:
$ zip -yr tmp.zip tmp
$ unzip tmp.zip -d newtmp
Archive: tmp.zip
creating: newtmp/tmp/
creating: newtmp/tmp/a/
extracting: newtmp/tmp/c
linking: newtmp/tmp/d -> c
linking: newtmp/tmp/b -> a
finishing deferred symbolic links:
newtmp/tmp/d -> c
newtmp/tmp/b -> a
$ tree newtmp
newtmp
└── tmp
├── a
├── b -> a
├── c
└── d -> c
I then attempted to use Zip4j to zip these files.
First attempt is a naive approach. Just setSymbolicLinkAction to INCLUDE_LINK_ONLY:
$ unzip test.zip -d test && tree test
Archive: test.zip
creating: test/tmp/
creating: test/tmp/a/
extracting: test/tmp/c
linking: test/tmp/d -> c
extracting: test/tmp/b
finishing deferred symbolic links:
test/tmp/d -> c
test
└── tmp
├── a
├── b
├── c
└── d -> c
2 directories, 3 files
That didn't work. The symlink b to directory a, did not stay a symlink.
Then I tried only setting INCLUDE_LINK_ONLY for paths tested to be symlinks, and manually set CompressionLevel.NO_COMPRESSION and CompressionMethod.STORE.
Toy example:
I created one directory with a symlink to it and a regular file with a symlink to it like so:
Ideally what would happen is the following:
I then attempted to use Zip4j to zip these files.
First attempt is a naive approach. Just
setSymbolicLinkAction
toINCLUDE_LINK_ONLY
:Let's see what it contains:
That didn't work. The symlink
b
to directorya
, did not stay a symlink.Then I tried only setting
INCLUDE_LINK_ONLY
for paths tested to be symlinks, and manually setCompressionLevel.NO_COMPRESSION
andCompressionMethod.STORE
.Unzipping output:
It still won't link
b
toa
!Originally posted by @ajpfahnl in https://github.com/srikanth-lingala/zip4j/issues/486