Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid tar header: unknown format. (for ExtendedName) #161

Open
jeroen opened this issue Oct 20, 2023 · 0 comments
Open

Invalid tar header: unknown format. (for ExtendedName) #161

jeroen opened this issue Oct 20, 2023 · 0 comments

Comments

@jeroen
Copy link

jeroen commented Oct 20, 2023

The attached tar.gz was created with the default settings using gnutar on a directory containing a large filename. It seems to automatically have switched on extended file attributes (the tar contains a file ExtendedName).

LHsampling_0.1.0.tar.gz

It errors when trying to extract with tar-stream: Invalid tar header: unknown format.

A workaround is to use var extract = tar.extract({allowUnknownFormat:true});

var fs = require('fs');
var tar = require('tar-stream');
var gunzip = require('gunzip-maybe');

tar_list('./LHsampling_0.1.0.tar.gz')

function tar_list(path){
  var input = fs.createReadStream(path);
  var extract = tar.extract();
  extract.on('entry', function(header, file_stream, next_entry) {
    console.log(header.name)
    next_entry();
    file_stream.resume();
  });
  extract.on('finish', function() {
    console.log("Done!")
  });
  extract.on('error', function(err) {
    console.log("ERROR", err)
  });
  return input.pipe(gunzip()).pipe(extract);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant