antelle / node-stream-zip

node.js library for fast reading of large ZIPs
Other
447 stars 63 forks source link

'Unknown compression method: 12' when extracting #85

Closed BertCatsburg closed 3 years ago

BertCatsburg commented 3 years ago

Hello,

I'm using node-stream-zip to unzip a file of 100Mb.

Program

The program (function) is as follows:

//@ts-nocheck
import StreamZip from 'node-stream-zip';
import fs from 'fs';

export const unzipFile = async ({source, target}: any) => {
    console.log(`File to unzip ${source}`);
    console.log(`Unzipping to ${target}`);

    const zip = new StreamZip.async({file: source});

    zip.on('extract', (entry, file) => {
        console.log(`Extracted ${entry.name} to ${file}`);
    });

    // * See the files in the zip
    const entriesCount = await zip.entriesCount;
    const entries = await zip.entries();
    for (const entry of Object.values(entries)) {
        const desc = entry.isDirectory ? 'directory' : `${entry.size} bytes`;
        console.log(`Entry ${entry.name}: ${desc}`);
    }

    const count = await zip.extract('export.xsl', target);
    console.log(`Extracted ${count} entries`);

    // Do not forget to close the file once you're done
    await zip.close();

    return;
}

Output

Entry export.xml: 11336260 bytes
Entry export.xsl: 6234 bytes
Entry Relations.xml: 1294142425 bytes
Entry Prices.xml: 2123073643 bytes
Entry Products.xml: 6449616837 bytes
Entry Settings.xml: 3183 bytes
Unknown compression method: 12

So, the node-stream-zip does see the different files in the zipfile. But, when I try to extract file, or try to extract everything, I get the message: Unknown compression method: 12

Filename

The zipfile is a good zipfile. I can unzip it with unarchiver (GUI-tool) and 7-zip (commandline tool) on OSX. The filename is called PRODUCTS_bzip2.zip

What does the compression method 12 mean?

antelle commented 3 years ago

Hi! It's BZIP2, we won't be able to support it.