Coder Social home page Coder Social logo

decompress-targz's Introduction

decompress-targz Build Status

tar.gz decompress plugin

Install

$ npm install decompress-targz

Usage

const decompress = require('decompress');
const decompressTargz = require('decompress-targz');

decompress('unicorn.tar.gz', 'dist', {
	plugins: [
		decompressTargz()
	]
}).then(() => {
	console.log('Files decompressed');
});

API

decompressTargz()(input)

Returns both a Promise for a Buffer and a Duplex stream.

input

Type: Buffer Stream

Buffer or stream to decompress.

License

MIT © Kevin Mårtensson

decompress-targz's People

Contributors

kevva avatar shinnn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

decompress-targz's Issues

Decompress files with their correct mtime

Currently decompressed files use extraction mtime instead the one when they where compressed, that lead to errors in some cases when decompressing source code tarballs (Makefile & friends...). tar-stream provides the mtime on the files headers, so they should be extracted using them.

No error handling for gunzip errors

(This probably applies to other decompress plugins as well.)

decompress-targz doesn't register an error handler on the gunzip stream, so any errors in gunzipping are thrown by some random callback rather than attached to the Promise returned by decompress.

See glasser/decompress@e42dc12 for a failing test demonstrating this issue.

RangeError [ERR_OUT_OF_RANGE]: The value of "length" is out of range. It must be >= 0 && <= 2147483647. Received 3179560960

When I try to extract a 3,1GB .targz archive, using this a stream pipe:

        const decompressTargz = require('decompress-targz');
        const stream = fs.createReadStream(tmpPath);
        const files = await decompressTargz()(stream);
        if(files && files.length && files[0].path) {
            // { data: Buffer, path: String }
            const myReadableStream = bufferToStream(files[0].data);
            myReadableStream
                .pipe(fs.createWriteStream(destPath))
                .on('close', async function () {
                    consoleLogger.info("wrote %s", destPath);
                })
                .on('error', (error) => {
                    consoleLogger.warn("gunzip error:%@", error.toString());
                })
        }

and the error was

internal/validators.js:97
      throw new ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value);
      ^

RangeError [ERR_OUT_OF_RANGE]: The value of "length" is out of range. It must be >= 0 && <= 2147483647. Received 3179560960
    at Object.write (fs.js:676:5)
    at WriteStream._write (internal/fs/streams.js:356:13)
    at WriteStream.<anonymous> (internal/fs/streams.js:349:12)
    at Object.onceWrapper (events.js:482:26)
    at WriteStream.emit (events.js:375:28)
    at WriteStream.emit (domain.js:470:12)
    at internal/fs/streams.js:340:12
    at FSReqCallback.oncomplete (fs.js:180:23) {
  code: 'ERR_OUT_OF_RANGE'
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.