mafintosh / tar-stream

tar-stream is a streaming tar parser and generator.
MIT License
400 stars 93 forks source link

How can I modify tar.gz? #121

Closed gloias closed 1 year ago

gloias commented 4 years ago

I want to modify a tar.gz file. I follow the procedure described in label "Modifying existing tarballs" but when my tar.gz is a little bigger(e.x. 20kb), it doesn't work. I noticed that every file of tar.gz is transferred to 'pack' and after some additions the pack memory is not enough to add the next files. How can I solve this problem?

alxpsr commented 2 years ago

@gloias I suppose you can't because of the data is compressed. Tarball aka tar is just a bundle of files, non compressed. That's why you can modify files inside of tar archive and can't inside of tar.gz files (and in zip as well). If i'm not mistaken

piranna commented 2 years ago

You need to decompress, modify, and re-compress. Modify tarfiles also has a trick, because you can't modify in place, just only overwrite with zeroes and append, to actual modify it you need to rewrite it.

A different topic if Google .gz.tar format, where each file is compressed independently, it's not so much compressed but allow to easier access and modify them.