You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importAdmZipfrom"adm-zip";letzip=newAdmZip("./test.zip");console.log("* Before delete of test/path1/:");zip.getEntries().forEach((entry)=>{console.log(entry.entryName);});zip.deleteFile("test/path1/");console.log("");console.log("* After delete of test/path1/:");zip.getEntries().forEach((entry)=>{console.log(entry.entryName);});
The result will be
* Before delete of test/path1/:
test/
test/path2/
test/path2/file1.txt
test/path2/folder1/
test/path2/folder1/file2.txt
test/path1/
test/path1/file1.txt
test/path1/folder1/
test/path1/folder1/file2.txt
* After delete of test/path1/:
test/
test/path2/
test/path2/file1.txt
test/path2/folder1/
As it can be seen during the deletion of /test/path1/ also /test/path2/folder1/file2.txt has been eliminated.
I have not debugged it to much, but from a first look to me it is that in the deleteFile function, in particular when eliminating the entry from the entryList here, the entry is not found and thus indexOf will return -1 that causes the elimination of the last element of the array.
Activity
5saviahv commentedon Aug 4, 2024
Hmm, it seems there is error when deleting folders with multiple levels deep (with sub folder(s) ).
File is already deleted and searching its location with IndexOf returns -1. Since there is no value check, it will simply delete last entry.
adm-zip/zipFile.js
Line 221 in ef63cbb
matteo-cristino commentedon Aug 5, 2024
Thank you very much for the quick fix! 🎉
Do you know when a new release will be done to have this bug fixed?
5saviahv commentedon Aug 10, 2024
fix should be in last release