mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-09 05:24:55 +00:00
ArchiveFactory fails with this "tar.gz" file #610
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jbrockerville on GitHub (Jan 3, 2024).
I made "archive-linux-tar.tar.gz" file with
tar -czf archive.tar.gz tar.gz.txt(attachment renamed) and theArchiveFactorycontains an entry with a nullKey. I think it might be usingGZipArchiveinstead ofTarArchive?I then made "archive-linux-tar-gzip.tar.gz" with
tar -cf archive.tar tar.gz.txtandgzip -5 archive.tar(attachment renamed) and that was fine.NGL, I'm not a huge Linux guy, so I'm assuming both methods of creating a "tar.gz" are valid.
archive-linux-tar.tar.gz
archive-linux-tar-gzip.tar.gz
@Erior commented on GitHub (Jan 4, 2024):
Tar files are forward reading archives (think old tape backup), try out the ReaderFactory, I think it will work much better for you.
I do see the detection for file.tar. is not really well supported for the ArchiveFactory, this could be improved, not sure what GZipArchive is supposed to do, it's not really an archive format as such.
Perhaps @adamhathcock can give advice on what is expected.
gzip as such may not contain a name for the file you compressed , check the "-N, --name" option, you can do "man gzip" or search on the web for more info regarding that.
@jbrockerville commented on GitHub (Jan 5, 2024):
Thanks for replying @Erior. The
ReaderFactoryworks for all the different tar-gz files I made. However, I'm not using theReaderFactorybecause using theArchiveFactorygets me 7Zip support. TheTarArchiveclass should handle the file I made. According to FORMATS.md anyways.Did you maybe get that backwards? The one-step file made with only
tarhas the nullKey. The two-step file made withtarand thengzipis handled just fine.@Erior commented on GitHub (Jan 5, 2024):
Problem, it is not detected as a Tar Archive, if you skip the name and just open the internal entry stream again you would get the tar archive.
For the second part, If you did "gzip -5n" you would get the same "no name" scenario for both streams.
@jbrockerville commented on GitHub (Jan 5, 2024):
Yeah, but I don't want to do that. But that's just my preference in this specific scenario--I want all the entries to have names. But a
nullKeyis prolly the same design decision I'd make here. Oh well. I'll work around it.Hmm... I guess that's what
taris doing with the-zflag. Prolly the other compression options, too. Seems valid then.Given all that, I guess this isn't a bug. Closing. Thanks for the discussion.
@adamhathcock commented on GitHub (Jan 8, 2024):
gzip is a compression around tar which is just a file format. Can't really have random access around a
tar.gzThere is a header for gzip that may contain the filename of the tar but it's not required....haven't looked at the file format for gzip for years.
Hope this helps