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

ZipException when remove file on android device : ivalid offsets #365

Closed
Fly946334 opened this issue Oct 11, 2021 · 4 comments
Closed

ZipException when remove file on android device : ivalid offsets #365

Fly946334 opened this issue Oct 11, 2021 · 4 comments
Assignees
Labels
bug Something isn't working resolved
Projects

Comments

@Fly946334
Copy link

When I use the tool(2.9.0) to delete the file in the zip (android device), I can get the fileHeader by looking at the file name as garbled on the PC side, but an error is reported when I use fileHeader or filename to delete it....However, it works normally in version 1.3.2
file name: 反折L型缺口板.SLDPRT.view
code:
ZipFile zipFile = new ZipFile(destFile);
String removeName = null;
try {
List fileHeaders = zipFile.getFileHeaders();
for (FileHeader fileHeader : fileHeaders) {
String name = fileHeader.getFileName();
if (name.endsWith(".view")) {
removeName = name;
break;
}
}
if (removeName == null)
return;
zipFile.removeFile(removeName);
} catch (ZipException e) {
e.printStackTrace();
}

Exception:

System.err: net.lingala.zip4j.exception.ZipException: invalid offsets
System.err: at net.lingala.zip4j.util.FileUtils.copyFile(FileUtils.java:305)
System.err: at net.lingala.zip4j.tasks.AbstractModifyFileTask.copyFile(AbstractModifyFileTask.java:72)
System.err: at net.lingala.zip4j.tasks.RemoveFilesFromZipTask.executeTask(RemoveFilesFromZipTask.java:67)
System.err: at net.lingala.zip4j.tasks.RemoveFilesFromZipTask.executeTask(RemoveFilesFromZipTask.java:22)
System.err: at net.lingala.zip4j.tasks.AsyncZipTask.performTaskWithErrorHandling(AsyncZipTask.java:51)
System.err: at net.lingala.zip4j.tasks.AsyncZipTask.execute(AsyncZipTask.java:45)
System.err: at net.lingala.zip4j.ZipFile.removeFiles(ZipFile.java:839)
System.err: at net.lingala.zip4j.ZipFile.removeFile(ZipFile.java:807)
System.err: at me.pqpo.zip4jdemo.MainActivity.testremove(MainActivity.java:48)

@srikanth-lingala
Copy link
Owner

Hi. Are you able to reproduce this issue with a zip file that you can share with me? Without the zip file it will be quite hard to see what is going wrong.

@Fly946334
Copy link
Author

Hi. Are you able to reproduce this issue with a zip file that you can share with me? Without the zip file it will be quite hard to see what is going wrong.

Thank you for your reply。I have sent the file to your mailbox(srikanth.mailbox@gmail.com

@srikanth-lingala
Copy link
Owner

Thanks for the zip file. I will take a look.

@srikanth-lingala srikanth-lingala self-assigned this Oct 19, 2021
@srikanth-lingala srikanth-lingala added bug Something isn't working in-progress labels Oct 19, 2021
@srikanth-lingala srikanth-lingala added this to To do in Zip4j via automation Oct 19, 2021
@srikanth-lingala srikanth-lingala moved this from To do to In progress in Zip4j Oct 19, 2021
@srikanth-lingala srikanth-lingala moved this from In progress to Review in Zip4j Nov 10, 2021
@srikanth-lingala
Copy link
Owner

Fixed in v2.9.1 released today.

Zip4j automation moved this from Review to Done Nov 18, 2021
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
Zip4j
  
Done
Development

No branches or pull requests

2 participants