srikanth-lingala / zip4j

A Java library for zip files and streams
Apache License 2.0
2.09k stars 313 forks source link

ZipFile.addFolder will delete the whole folder that already exist in zipfile #558

Open zeroonead opened 3 months ago

zeroonead commented 3 months ago

Hello Sorry, English is not good. my zip4j version is 2.11.5, OS is windows 11, jdk 1.8,here is the code

ZipParameters zipParameters = new ZipParameters();  
zipParameters.setRootFolderNameInZip("lib");    
ZipFile zipFile = new ZipFile(apkPath);  
zipFile.addFolder(new File(myFolder), zipParameters);

the zipfile already exist the "lib" folder,some files like "lib/aa.txt" (the folder that i added did not have this files),but after zipFile.addFolder,the whole "lib" folder files was deleted, only the files that I added was lefted in zipfile.

what should I do to not delete the "lib" folder files that already exist in zipfile.

zeroonead commented 3 months ago

I solve it by use addFiles instead of addFolder, like this

zipParameters.setRootFolderNameInZip("lib/arm64-v8a");
zipFile.addFiles(FileUtil.scanAllFile(myFolder, null), zipParameters);

is it a bug of addFolder?