Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-8260

Error when unzipping build zip package

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • None
    • None
    • cordova-browser
    • None

    Description

      When I build my project with 'cordova build browser', a zip file will be created under the build folder. When I unzip that folder I get the following errors for certain files:

      error: invalid compressed data to inflate

      It seems that the problem lays in the adm-zip module used to create that zip package. Other people have reported the same issue in the issue tracker of adm-zip (https://github.com/cthackers/adm-zip/issues/102).

      This could be solved by using another archiver module like https://github.com/ctalkington/node-archiver as suggested by another user in the issue tracker of adm-zip.

      Attachments

        Issue Links

          Activity

            leowa Leo Wandersleb added a comment - - edited

            Same here. Sam could you share how you worked around this? I only started looking into it. If not, I'll provide a workaround tomorrow.

            My deploy script currently does this:

            cordova build browser --release
            scp platforms/browser/build/package.zip $SERVER:$FOLDER
            ssh $SERVER 'cd '$FOLDER';unzip -o package.zip;rm package.zip'

            and sound and font files cause issues.

            ========

            Edit: looks like the build browser script doesn't do anything special.

            platforms/browser/cordova/lib/build.js:

            platformWwwDir = path.join('platforms', 'browser', 'www'),
            var zipFile = zip();
            zipFile.addLocalFolder(platformWwwDir, '.');
            zipFile.writeZip(packageFile);

            seam to be all the lines relevant here, so I will just zip it up myself or rsync or something.

            leowa Leo Wandersleb added a comment - - edited Same here. Sam could you share how you worked around this? I only started looking into it. If not, I'll provide a workaround tomorrow. My deploy script currently does this: cordova build browser --release scp platforms/browser/build/package.zip $SERVER:$FOLDER ssh $SERVER 'cd '$FOLDER';unzip -o package.zip;rm package.zip' and sound and font files cause issues. ======== Edit: looks like the build browser script doesn't do anything special. platforms/browser/cordova/lib/build.js: platformWwwDir = path.join('platforms', 'browser', 'www'), var zipFile = zip(); zipFile.addLocalFolder(platformWwwDir, '.'); zipFile.writeZip(packageFile); seam to be all the lines relevant here, so I will just zip it up myself or rsync or something.

            Hi Leo

            Yes, it looks like it only happens with non-text files. What I did was creating the zip and manually uploading my font-files (and I guess images aswell).

            The code to generate the zip doesn't do much because it uses the adm-zip module. The only thing is, is that adm-zip has a bug itself when zipping those files. As I suggested, they could use node-archiver.

            Maybe I should implement it and add a pull request on their github pages. Not sure if they will accept it though.

            Curahee Sam Verschueren added a comment - Hi Leo Yes, it looks like it only happens with non-text files. What I did was creating the zip and manually uploading my font-files (and I guess images aswell). The code to generate the zip doesn't do much because it uses the adm-zip module. The only thing is, is that adm-zip has a bug itself when zipping those files. As I suggested, they could use node-archiver. Maybe I should implement it and add a pull request on their github pages. Not sure if they will accept it though.
            leowa Leo Wandersleb added a comment -

            With "doesn't do much" I was referring to me understanding the script. It's nothing but the buggy zipping in there.

            leowa Leo Wandersleb added a comment - With "doesn't do much" I was referring to me understanding the script. It's nothing but the buggy zipping in there.
            amikula Alf Mikula added a comment -

            I'm running into this with my index.html file. It appears to be related to the length of that file...if I delete lines from the beginning or end of the file, both actions cause the file not to get corrupted in the zip.

            amikula Alf Mikula added a comment - I'm running into this with my index.html file. It appears to be related to the length of that file...if I delete lines from the beginning or end of the file, both actions cause the file not to get corrupted in the zip.

            For whoever is interested, I forked a version of the browser platform which uses a fixed version of the adm-zip module. Can be found here:
            https://github.com/rafelbev/cordova-browser

            rafelbev Raphael Borg Ellul Vincenti added a comment - For whoever is interested, I forked a version of the browser platform which uses a fixed version of the adm-zip module. Can be found here: https://github.com/rafelbev/cordova-browser
            githubbot ASF GitHub Bot added a comment -

            GitHub user VinceOPS opened a pull request:

            https://github.com/apache/cordova-browser/pull/25

            CB-8260: (browser) Fix corrupted zip file (build)

            <!--
            Please make sure the checklist boxes are all checked before submitting the PR. The checklist
            is intended as a quick reference, for complete details please see our Contributor Guidelines:

            http://cordova.apache.org/contribute/contribute_guidelines.html

            Thanks!
            -->

                1. Platforms affected
                  Platform "browser" only.
                1. What does this PR do?
                  Replace the node module `adm-zip`, which is known for corrupting some files when compressing a folder to a zip archive, by the module `archiver`.
                  Update the build script in order to use `archiver` instead of `adm-zip`.
                1. What testing has been done on this change?
                  Making sure that all the different types of file bundled in the newly built package.zip were properly compressed, and uncompressed.
                1. Checklist
            • [X] [Reported an issue](http://cordova.apache.org/contribute/issues.html) in the JIRA database
            • [X] Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected.
            • [X] Added automated test coverage as appropriate for this change.

            You can merge this pull request into a Git repository by running:

            $ git pull https://github.com/VinceOPS/cordova-browser master

            Alternatively you can review and apply these changes as the patch at:

            https://github.com/apache/cordova-browser/pull/25.patch

            To close this pull request, make a commit to your master/trunk branch
            with (at least) the following in the commit message:

            This closes #25


            commit 4ea3ad76414727e732e80ce69e100522e5dddc92
            Author: Vince <vince.g.135@gmail.com>
            Date: 2016-12-01T22:50:23Z

            CB-8260: (browser) Fix corrupted zip file (build)


            githubbot ASF GitHub Bot added a comment - GitHub user VinceOPS opened a pull request: https://github.com/apache/cordova-browser/pull/25 CB-8260 : (browser) Fix corrupted zip file (build) <!-- Please make sure the checklist boxes are all checked before submitting the PR. The checklist is intended as a quick reference, for complete details please see our Contributor Guidelines: http://cordova.apache.org/contribute/contribute_guidelines.html Thanks! --> Platforms affected Platform "browser" only. What does this PR do? Replace the node module `adm-zip`, which is known for corrupting some files when compressing a folder to a zip archive, by the module `archiver`. Update the build script in order to use `archiver` instead of `adm-zip`. What testing has been done on this change? Making sure that all the different types of file bundled in the newly built package.zip were properly compressed, and uncompressed. Checklist [X] [Reported an issue] ( http://cordova.apache.org/contribute/issues.html ) in the JIRA database [X] Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected. [X] Added automated test coverage as appropriate for this change. You can merge this pull request into a Git repository by running: $ git pull https://github.com/VinceOPS/cordova-browser master Alternatively you can review and apply these changes as the patch at: https://github.com/apache/cordova-browser/pull/25.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #25 commit 4ea3ad76414727e732e80ce69e100522e5dddc92 Author: Vince <vince.g.135@gmail.com> Date: 2016-12-01T22:50:23Z CB-8260 : (browser) Fix corrupted zip file (build)
            githubbot ASF GitHub Bot added a comment -

            Github user purplecabbage commented on the issue:

            https://github.com/apache/cordova-browser/pull/25

            I like this, and thank you, however, I am planning on removing zip functionality.
            I believe zipping was only added because someone decided that `build` needed some sort of output.
            Realistically, I think it makes more sense to let users zip their own build output as they see fit, and remove these extra deps.

            githubbot ASF GitHub Bot added a comment - Github user purplecabbage commented on the issue: https://github.com/apache/cordova-browser/pull/25 I like this, and thank you, however, I am planning on removing zip functionality. I believe zipping was only added because someone decided that `build` needed some sort of output. Realistically, I think it makes more sense to let users zip their own build output as they see fit, and remove these extra deps.
            githubbot ASF GitHub Bot added a comment -

            Github user asfgit closed the pull request at:

            https://github.com/apache/cordova-browser/pull/25

            githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/cordova-browser/pull/25

            Zipping is (todo being removed from browser platform builds.

            purplecabbage Jesse MacFadyen added a comment - Zipping is (todo being removed from browser platform builds.

            People

              Unassigned Unassigned
              Curahee Sam Verschueren
              Votes:
              3 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: