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

Exception raised when zipping a symbolic link #433

Closed
DevLazio opened this issue Jun 3, 2022 · 4 comments
Closed

Exception raised when zipping a symbolic link #433

DevLazio opened this issue Jun 3, 2022 · 4 comments
Assignees
Labels
bug Something isn't working resolved

Comments

@DevLazio
Copy link

DevLazio commented Jun 3, 2022

When trying to zip a folder containing a symbolic link to /tmp/ I encounter the following error :

net.lingala.zip4j.exception.ZipException: java.lang.StringIndexOutOfBoundsException: String index out of range: -5
        at net.lingala.zip4j.tasks.AsyncZipTask.performTaskWithErrorHandling(AsyncZipTask.java:58)
        at net.lingala.zip4j.tasks.AsyncZipTask.execute(AsyncZipTask.java:45)
        at net.lingala.zip4j.ZipFile.addFolder(ZipFile.java:390)
        at net.lingala.zip4j.ZipFile.addFolder(ZipFile.java:365)

I'm trying to zip a folder with this structure :
image
cogi8.zip

Changing the SymbolicLinkAction did not help.

@srikanth-lingala srikanth-lingala added bug Something isn't working in-progress labels Jun 6, 2022
@srikanth-lingala
Copy link
Owner

I was able to reproduce this issue. Working on a fix.

@srikanth-lingala
Copy link
Owner

Fixed in v2.11.0 released today

@Hronom
Copy link

Hronom commented Sep 3, 2022

Hey @srikanth-lingala still valid in 2.11.1, I'm trying to zip this repository https://github.com/JetBrains/compose-jb and get error

Symlink target '../../../../../../../prebuilts/androidx/exoplayer/exoplayer-media2.jar' does not exist for link '{hided}/compose-jb/compose/frameworks/support/media2/media2-exoplayer/src/main/libs/exoplayer-media2.jar'

Here my code on Kotlin:

        val zipParameters = ZipParameters()
        zipParameters.isOverrideExistingFilesInZip = true
        zipParameters.compressionLevel = CompressionLevel.ULTRA

        val file = File("$absolutePath.zip")
        file.delete()

        ZipFile(file).use {
            it.isRunInThread = true
            val progressMonitor = it.progressMonitor
            it.addFolder(File(absolutePath), zipParameters)
            while (!progressMonitor.state.equals(ProgressMonitor.State.READY)) {
                onProgress(progressMonitor.percentDone)
                println(progressMonitor.percentDone)
                delay(1000L)
            }
            if (progressMonitor.result.equals(ProgressMonitor.Result.ERROR)) {
                throw IllegalStateException(progressMonitor.exception)
            }
        }

Java 17

@Hronom
Copy link

Hronom commented Sep 3, 2022

Oh looks like able to solve by adding this param:

        zipParameters.symbolicLinkAction = ZipParameters.SymbolicLinkAction.INCLUDE_LINK_ONLY

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working resolved
Projects
None yet
Development

No branches or pull requests

3 participants