Skip to content

Error Zipping Folder with many files or sub folders #7

Open

Description

@chelinho139

Hey, so I am trying to zip my DB backup, it has like 100.000 folders, and it throws an:
Error: EMFILE: too many open files

However, i am able to zip it manually using linux:
zip -r backupDB_2017-6-15.zip backupDB_2017-6-15

Hope someone can help me out...

This is the error stacktrace I get:


events.js:141
      throw er; // Unhandled 'error' event
      ^

Error: EMFILE: too many open files, scandir '/home/centos/server/backupDB_2017-6-14'
    at Error (native)
    at Object.fs.readdirSync (fs.js:808:18)
    at Glob._readdir (/home/centos/server/scheduler/node_modules/zip-folder/node_modules/archiver/node_modules/glob/glob.js:662:20)
    at Glob._process (/home/centos/server/scheduler/node_modules/zip-folder/node_modules/archiver/node_modules/glob/glob.js:446:15)
    at Glob.iterator (/home/centos/server/scheduler/node_modules/zip-folder/node_modules/archiver/node_modules/glob/glob.js:181:10)
    at Array.forEach (native)
    at new Glob (/home/centos/server/scheduler/node_modules/zip-folder/node_modules/archiver/node_modules/glob/glob.js:179:22)
    at glob (/home/centos/server/scheduler/node_modules/zip-folder/node_modules/archiver/node_modules/glob/glob.js:57:11)
    at Function.globSync [as sync] (/home/centos/server/scheduler/node_modules/zip-folder/node_modules/archiver/node_modules/glob/glob.js:76:10)
    at /home/centos/server/scheduler/node_modules/zip-folder/node_modules/archiver/lib/util/file.js:62:17
    at /home/centos/server/scheduler/node_modules/zip-folder/node_modules/archiver/lib/util/file.js:30:19
    at Array.forEach (native)
    at processPatterns (/home/centos/server/scheduler/node_modules/zip-folder/node_modules/archiver/lib/util/file.js:24:23)
    at Object.file.expand (/home/centos/server/scheduler/node_modules/zip-folder/node_modules/archiver/lib/util/file.js:60:17)
    at Object.file.expandMapping (/home/centos/server/scheduler/node_modules/zip-folder/node_modules/archiver/lib/util/file.js:94:8)
    at /home/centos/server/scheduler/node_modules/zip-folder/node_modules/archiver/lib/util/file.js:159:19

Thanks!

Activity

  1. changed the title [-]Error Zipping Folder with many files sub folders[/-] [+]Error Zipping Folder with many files or sub folders[/+] on Jun 18, 2017
  2. arunkumarpalaniappan commented on Jun 20, 2017

    @arunkumarpalaniappan

    Hi @chelinho139 Issue is fixed in #8

  3. chelinho139 commented on Jun 20, 2017

    @chelinho139
    Author

    @arunkumarpalaniappan how can I pull that?

  4. arunkumarpalaniappan commented on Jun 20, 2017

    @arunkumarpalaniappan

    @chelinho139

    You can't get it in npm until @sole accepts the PR.

    But you can use the below snippet to make it work

    P.S: Install Archiver using npm install archiver

    const fs = require('fs');
    const archiver = require('archiver');
    const zipFolder = (srcFolder, zipFilePath, callback) => {
    var output = fs.createWriteStream(zipFilePath);
    var zipArchive = archiver('zip');
    output.on('close', function() {
    callback();
    });
    zipArchive.pipe(output);
    zipArchive.glob('**/*',
    { cwd: srcFolder,
    src: ['**/*'],
    expand: true }
    );
    zipArchive.finalize(function(err, bytes) {
    if(err) {
    callback(err);
    }
    });
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions