FortuneN / cordova-plugin-zeep

Zip compression/decompression for the cordova/phonegap platform
Apache License 2.0
28 stars 37 forks source link

unzip behaves weirdly on windows #16

Closed Harha closed 6 years ago

Harha commented 6 years ago

from: ms-appdata:///local/LOCALSTORAGE_BACKUP.bak to: ms-appdata:///local/demo/

On android, this 'demo' folder is created upon unzip if it doesn't exist + .bak file contents are unzipped there correctly. On windows (Windows 10, UWP) it is created but it remains empty, meaning no files were actually unzipped from the .bak archive into the destination folder.

More weirdness: I tried this as output: ms-appdata:///local/demo/data.json, I knew it wouldn't work since it is by definition just asking for the folder path where to extract. To my surprise it created data.json folder and it did contain the extracted files.

Something weird going on there, I'm quite sure about that. I'm using cordova-plugin-file and cordova-plugin-zeep both. Everything works on android, nearly everything works on windows (unzip is only thing that has problems AFAIK).

Good job on the plugin so far! (y)

Harha commented 6 years ago

@FortuneN I did a bit more testing.

1.) unzip produces the zip file contents on destination path IF the destination path 'to' does not end with a forward slash.

2.) The unzipped files contain NULL characters. I've only been handling text files (JSON) and those are cut at random points and the rest of the file is just NULL NULL NULL 'till the end. The file sizes are always correct.

edit: Could you try to update SharpZipLib ?

Harha commented 6 years ago

I fixed it. I'll send a pull request.

tfairfield commented 6 years ago

Could there be an issue when the zip file itself contains folders? I am having a failure to unzip on Windows as well, even after applying above fix, and checking that the destination folder does not end with a forward slash, as mentioned.

My zipped file mirrors a server location and contains a subfolder structure like this: var/www/project/web/public/contents/static/2/[files]

The unzip is successful, but the destination is empty.

The code I am using is:

declare let Zeep: any;
Zeep.unzip({
                    from : cordova.file.cacheDirectory + "dwnlds/file.zip",
                    to   : cordova.file.dataDirectory+'mydir'