SharpCompress fails to validate tar compressed using zstd #692

Closed
opened 2026-01-29 22:16:00 +00:00 by claunia · 4 comments
Owner

Originally created by @SimonCahill on GitHub (Jul 14, 2025).

It's been a while since I've actively used this library, but I'd had good experiences in the past, so I decided to use it once more.

I have the following test case:

[TestMethod]
public async Task TestCompressDirectory_ZstCompressedTar_FileInRoot() {
    var tmpFile = Path.GetTempFileName();
    var fileBytes = GenerateRandomMemory(4096);
    File.WriteAllBytes(tmpFile, fileBytes.ToArray());

    var tmpPath = new DirectoryInfo(Path.Combine(Path.GetTempPath(), "HermodTests", "EmailArchiverTests", nameof(TestCompressDirectory_ZstCompressedTar_FileInRoot)));
    tmpPath.Create();

    File.Move(tmpFile, Path.Combine(tmpPath.FullName, Path.GetFileName(tmpFile)));

    await m_emailArchiver.CompressDirectoryAsync(tmpPath, CompressionType.Squeezed);
    var expectedPath = Path.Combine(tmpPath.Parent?.FullName ?? string.Empty, $"{nameof(TestCompressDirectory_ZstCompressedTar_FileInRoot)}.tzst");

    Assert.IsTrue(File.Exists(expectedPath), $"Archive file ({expectedPath}) was not created.");

    using var fStream = File.OpenRead(expectedPath);

    if (fStream.Length < 512) {
        // This is likely not a valid Zstandard compressed file.
        Assert.Fail($"Archive file ({expectedPath}) is not a valid Zstandard compressed file.");
    }

    Assert.IsTrue(VerifyTarHeader(), $"Archive file ({expectedPath}) is not a valid TAR file after decompression.");

    fStream.Seek(0, SeekOrigin.Begin);
    using var zstDecompStream = new DecompressionStream(fStream);
    using var tarArchive = TarArchive.Open(zstDecompStream);

    var entries = tarArchive.Entries.ToList(); // HERE!

    Assert.IsTrue(entries.Any(), $"Archive file ({expectedPath}) is empty.");

    bool VerifyTarHeader() {
        using var zstDecompStream = new DecompressionStream(fStream);

        Assert.IsTrue(zstDecompStream.CanRead, $"Archive file ({expectedPath}) is not a valid Zstandard compressed stream.");
        return TarArchive.IsTarFile(zstDecompStream);
    }
}

Interestingly, it fails to detect the tar header in the marked line.

The VerifyTarHeader method works as expected and doesn't throw.

Checking the debugger, I get the following information:

Image
   at SharpCompress.Archives.Tar.TarArchive.<LoadEntries>d__11.MoveNext()
   at SharpCompress.Helpers.LazyReadOnlyCollection`1.LazyLoader.MoveNext()
   at SharpCompress.Helpers.Utility.ForEach[T](IEnumerable`1 items, Action`1 action)
   at SharpCompress.Helpers.LazyReadOnlyCollection`1.EnsureFullyLoaded()
   at SharpCompress.Archives.AbstractArchive`2.SharpCompress.Archives.IArchiveExtractionListener.EnsureEntriesLoaded()
   at SharpCompress.Archives.AbstractArchive`2.get_IsComplete()

Below is a hex dump of the zst file:

00000000: 28b5 2ffd 0058 8588 00bc 0d01 2e61 7263  (./..X.......arc
00000010: 6869 6e66 6f00 2020 2020 3737 3720 2030  hinfo.    777  0
00000020: 2020 3233 3400 3135 3033 3532 3534 3635    234.1503525465
00000030: 3200 2020 2035 3531 3420 4845 524d 4f44  2.   5514 HERMOD
00000040: 0000 0098 0100 0000 1095 6f75 5f41 1a86  ..........ou_A..
00000050: 4d95 9fbe c2fe ef1c bd00 0000 20f7 1fae  M........... ...
00000060: d45b 80e6 eace e16a 62ec eabf 79ce d1ad  .[.....jb...y...
00000070: 9b6d 1a81 0622 714d 3c9b 9c52 a900 0000  .m..."qM<..R....
00000080: 552f 746d 702f 4865 726d 6f64 5465 7374  U/tmp/HermodTest
00000090: 732f 456d 6169 6c41 7263 6869 7665 7254  s/EmailArchiverT
000000a0: 6573 7443 6f6d 7072 6573 7344 6972 6563  estCompressDirec
000000b0: 746f 7279 5f5a 6564 5461 725f 4669 6c65  tory_ZedTar_File
000000c0: 496e 526f 6f74 746d 7031 6259 5246 4b2e  InRoottmp1bYRFK.
000000d0: 746d 7031 3030 3030 3632 3133 b1f3 d49f  tmp100006213....
000000e0: 3ebf dee4 1b44 8743 e3f7 79b7 6df4 94bc  >....D.C..y.m...
000000f0: bc55 f538 f52c a68f 0502 5841 707b 0963  .U.8.,....XAp{.c
00000100: 3525 d66e e113 5497 3af4 3406 2a22 4aea  5%.n..T.:.4.*"J.
00000110: 101b 2cb7 98aa c4b5 f0fe 0b60 a614 5df0  ..,........`..].
00000120: c26c 8490 525a 50a7 1870 b3e3 fb02 e697  .l..RZP..p......
00000130: 2bf6 8cc4 3c80 fdf6 6c37 5754 dcc8 9760  +...<...l7WT...`
00000140: 34ce 2011 c978 7dcf a4b3 54f3 ae13 8281  4. ..x}...T.....
00000150: 1fc3 aa82 1263 4761 337a b3cd 87b3 6c32  .....cGa3z....l2
00000160: 040b b64f a11d 90e9 c1ae 372d a9d8 4765  ...O......7-..Ge
00000170: bebd 1f0b 1709 a823 7055 4f98 2d4d cbfe  .......#pUO.-M..
00000180: 7f4b 38fb 520a df3b d4a8 2ea6 2c51 704d  .K8.R..;....,QpM
00000190: 0aba 20dd 8608 dcf5 d3ad 50df d8ea 6853  .. .......P...hS
000001a0: 3311 0dbd cf01 d2b6 9f3a b51f 659d db19  3........:..e...
000001b0: 7cfe 0ff7 83ab 5913 7d66 15e6 6a0e a207  |.....Y.}f..j...
000001c0: f0e4 3379 a10f 543c 0eec 80de 171b 1767  ..3y..T<.......g
000001d0: 39a6 9485 2671 0b66 f4a3 f3b9 425a 4489  9...&q.f....BZD.
000001e0: a681 9921 42e1 ed9b 5f46 7faa d64a 8a31  ...!B..._F...J.1
000001f0: dca0 d65d 4fc5 0056 cf71 19ee 0af8 3e56  ...]O..V.q....>V
00000200: a06b 9c18 76a0 3685 52a2 b9e8 5d10 0777  .k..v.6.R...]..w
00000210: 4274 4de5 bdfb ada8 b916 dd82 99a6 3f70  BtM...........?p
00000220: 6ed3 fc8e efec be0f b960 680a 3b25 8ba7  n........`h.;%..
00000230: 13e8 344e 808a 0041 7293 74b3 9d09 6323  ..4N...Ar.t...c#
00000240: 8f25 b250 f124 9290 044d 34b3 45bb b644  .%.P.$...M4.E..D
00000250: 255c 405e 14ac 3287 f157 f701 d105 efcc  %\@^..2..W......
00000260: 3502 b133 0637 91e5 dc36 d3c8 530a 3adb  5..3.7...6..S.:.
00000270: 975a 8230 d1f8 c318 c481 a67a a455 56c5  .Z.0.......z.UV.
00000280: c77d f9b2 9b8b 823d abeb c5d0 0234 73cf  .}.....=.....4s.
00000290: 21dc 053c 9219 0510 e09c 7ce3 9bbe ef3e  !..<......|....>
000002a0: 705c f485 191b 4421 cfbd e7cf b405 60f6  p\....D!......`.
000002b0: a355 856f 5f91 aa7f a702 66d2 b599 f41a  .U.o_.....f.....
000002c0: 925a 08e9 b946 d6c7 fe30 2e4b 2a6b 2438  .Z...F...0.K*k$8
000002d0: 99d4 da3c 40e0 1f95 09ea a7fb edae 3405  ...<@.........4.
000002e0: 1eee f2cb c4bc 2369 25cb aabf 5627 a9d5  ......#i%...V'..
000002f0: 148b 3ebe 84ae 3bf8 5707 1ca0 1a86 e4e7  ..>...;.W.......
00000300: 6adb 19b2 0a64 41dd ff2e b9c6 d860 927a  j....dA......`.z
00000310: 53ee ef81 4b8e 4904 55e8 e429 c753 6085  S...K.I.U..).S`.
00000320: 7aac d302 4588 512a c6a0 0416 49cd 335e  z...E.Q*....I.3^
00000330: 9ae0 1ca0 8ffd 226c e35f 7536 c742 7060  ......"l._u6.Bp`
00000340: 0b6a 2231 a981 8082 b27a 6f28 c082 a569  .j"1.....zo(...i
00000350: 1653 c34c 21b8 8ede dbd8 dd8a 79e3 94a7  .S.L!.......y...
00000360: cc38 aab6 4f71 e9df 7f7a f0ef cdf2 0a9e  .8..Oq...z......
00000370: 3784 bed9 92b1 bc6b 6334 5099 10b8 5611  7......kc4P...V.
00000380: 4a95 d439 dc5c 344c cd4e 6bef 3542 fa7f  J..9.\4L.Nk.5B..
00000390: 81bc fee4 2c1a 65e0 d906 83d4 cc50 5a06  ....,.e......PZ.
000003a0: 6b19 7e34 2989 7f18 ea96 7c56 e785 4afd  k.~4).....|V..J.
000003b0: f4c8 a8c5 34ed 43f7 d56c 4802 8195 b913  ....4.C..lH.....
000003c0: 92bf 241a 648c 10f9 d5d4 fdc5 7335 1938  ..$.d.......s5.8
000003d0: 0ee1 d2fb 091f 4416 2a9d 71f5 73da 1463  ......D.*.q.s..c
000003e0: bde9 3339 74d1 5ea6 9a5d 77b1 32e9 6e4c  ..39t.^..]w.2.nL
000003f0: 034f f92d 1495 aa0b 4030 e49b 2f33 015e  .O.-....@0../3.^
00000400: c108 31d0 e12d 6820 a984 8974 4c18 0583  ..1..-h ...tL...
00000410: 0474 27c8 1724 ffe6 1ba4 73f4 be22 656c  .t'..$....s.."el
00000420: 544d ba04 80d4 4fdf 474f 1c73 93d3 7a66  TM....O.GO.s..zf
00000430: 3213 17ff de7f 8db1 01bb d9fe c068 acd3  2............h..
00000440: 2744 88da e04e 9ac8 17e9 0f19 fccf e45a  'D...N.........Z
00000450: e809 9e78 cc12 ad83 f69a ac25 4c72 0753  ...x.......%Lr.S
00000460: 6c0e 1a73 67d8 0c1d 420b 9af9 6dc4 99a8  l..sg...B...m...
00000470: 7c9c 36fb 4ed8 b87b 004a 2ceb b3c4 7ab8  |.6.N..{.J,...z.
00000480: 7af1 c28b 849b 2181 b039 8ce1 0e0d c745  z.....!..9.....E
00000490: 8644 b58b 24b8 d79e 283a 6652 1021 fc42  .D..$...(:fR.!.B
000004a0: b374 94c2 6a6a 01a5 95c9 fad8 a407 4630  .t..jj........F0
000004b0: 521a f782 804a b804 35ef 3f37 5b02 282f  R....J..5.?7[.(/
000004c0: c9c6 adec cc91 c40f 07d5 3e48 7b75 ef78  ..........>H{u.x
000004d0: 5c0e 2b2b 48b7 1f21 c7d9 ee72 e9e3 e073  \.++H..!...r...s
000004e0: ef57 116a e6bd 4454 1fa7 0841 f518 2c78  .W.j..DT...A..,x
000004f0: 514b cd5e 9fc4 0dc0 73f3 5f30 70e2 1ab2  QK.^....s._0p...
00000500: 3fb7 0a38 eaec b7f2 068d fc0d 3e80 a421  ?..8........>..!
00000510: 344f b5f3 ca68 467c f2cc 0c14 df52 c1b2  4O...hF|.....R..
00000520: faf2 5117 98bf 85bc 47ae b2ef 438c 2886  ..Q.....G...C.(.
00000530: 3988 b669 413a 1420 758f cd11 6a52 4be6  9..iA:. u...jRK.
00000540: 53c8 381f 30af 69ac de13 93be 2ce6 31cc  S.8.0.i.....,.1.
00000550: a394 fcec 9948 1dd7 5e54 dfb2 503e 7208  .....H..^T..P>r.
00000560: 007b 2361 535e a76f 7c06 88f7 4e27 aff5  .{#aS^.o|...N'..
00000570: 5935 fa5f 0c9d 2981 4c3e 2afc 94fe 6805  Y5._..).L>*...h.
00000580: 2f1e d984 0a3b 2f74 6047 339e 1537 e533  /....;/t`G3..7.3
00000590: d4a5 ed93 2dac 091c b9f7 bac5 0802 e5f5  ....-...........
000005a0: b5fe be19 052d ae34 4360 c077 4b4c 9db1  .....-.4C`.wKL..
000005b0: e66e 2366 2e6b 570f f7d2 4498 3388 b3e1  .n#f.kW...D.3...
000005c0: 1d92 40c9 fa41 ff23 622e 7d81 acdd 5d96  ..@..A.#b.}...].
000005d0: c778 1827 5528 082d 291e 9a59 a2a2 95dd  .x.'U(.-)..Y....
000005e0: 87a4 b761 af3c 76d2 6305 ed60 e51f 4529  ...a.<v.c..`..E)
000005f0: 4cd6 4ca2 d738 0cb8 4b63 6a93 da2d 657c  L.L..8..Kcj..-e|
00000600: 44e2 238d b3b9 7d0d 0eb3 aa76 5819 0b1e  D.#...}....vX...
00000610: fa44 0f8e 7432 89b3 c81e 597a 9071 911a  .D..t2....Yz.q..
00000620: a675 24e6 48e0 7923 38e8 4291 5883 2c08  .u$.H.y#8.B.X.,.
00000630: 141e 1fbc 3963 62b2 6148 1a7a 44f6 2e68  ....9cb.aH.zD..h
00000640: c1b9 23ac c50f d8a9 c1ca 259b a93e 0d15  ..#.......%..>..
00000650: 8991 b292 9b07 704d ea90 f372 c794 ad3d  ......pM...r...=
00000660: 7106 a23d 7245 d049 ac17 1810 58af af20  q..=rE.I....X..
00000670: c5eb 8e97 488f 9409 4f5c 1555 9d51 8fba  ....H...O\.U.Q..
00000680: 8600 d51c 48e5 3485 f8a7 d953 8eef 5477  ....H.4....S..Tw
00000690: 5fc5 f88f 4824 c265 3bf2 456a 99b3 0ae4  _...H$.e;.Ej....
000006a0: b6f1 8812 4510 dc34 3fd3 bb0e 0004 6987  ....E..4?.....i.
000006b0: 8e2c fdf6 9900 d33f 01a2 442d c7be 5a5c  .,.....?..D-..Z\
000006c0: 5980 4ba9 2387 6ec9 efe1 905e c0ab d67f  Y.K.#.n....^....
000006d0: 740a 26f7 d897 7deb f023 3bf4 d1da 1dff  t.&...}..#;.....
000006e0: f07e 7e9c 9700 07d3 f3f8 ff47 3305 2e2f  .~~........G3../
000006f0: b7fd 955d 0595 66e6 5598 09f2 8be8 a359  ...]..f.U......Y
00000700: 7c23 cd2a 872f f6b6 d24c 867c 5a7e 4249  |#.*./...L.|Z~BI
00000710: 46ce 9e8f 64bc b159 1864 571b e0d5 07d2  F...d..Y.dW.....
00000720: 6f2a 8371 f132 554f 19ed 1054 9d71 7edf  o*.q.2UO...T.q~.
00000730: 496a b0e6 0638 d819 fe1d 7c30 ff5c 7385  Ij...8....|0.\s.
00000740: ea07 1804 484e d28f eeb1 a163 389d 9a2b  ....HN.....c8..+
00000750: b243 3af7 55a4 3421 ebe9 436f 216f 5587  .C:.U.4!..Co!oU.
00000760: b072 9328 b7d9 8389 10f7 1a2b dadc 72b6  .r.(.......+..r.
00000770: b864 3e3f 2895 2025 6c8f c279 7056 3a4e  .d>?(. %l..ypV:N
00000780: efe0 1989 491c 22a8 8c9f c730 11d5 0745  ....I."....0...E
00000790: a7dd d496 a850 7d19 59a1 f132 69ab df08  .....P}.Y..2i...
000007a0: c258 7004 0ced 8100 f525 c67a c82e 4fa1  .Xp......%.z..O.
000007b0: c7d0 483a 34f3 9975 3906 f6cd b7ed 8ca2  ..H:4..u9.......
000007c0: 3d7d 7ae8 0d3d a0ca 18c0 fa58 0b42 6956  =}z..=.....X.BiV
000007d0: 301b f7de 25a4 9868 09a1 4eb4 01c6 f5ba  0...%..h..N.....
000007e0: 45d3 b901 38e0 725c a637 52c0 a9f3 0c9b  E...8.r\.7R.....
000007f0: d60f 0f67 ecf5 dc08 a396 6997 28a0 3e60  ...g......i.(.>`
00000800: 06b2 a32f 52e5 62e6 8699 1914 9012 57f4  .../R.b.......W.
00000810: bc21 2425 4f4b 3e51 963f 2eb4 50c1 c9dd  .!$%OK>Q.?..P...
00000820: 93f1 e76f 10f1 9562 3c1d 3a44 a96b c93e  ...o...b<.:D.k.>
00000830: 5309 1f27 ed8f 824b 0db1 b91e e8a4 f64e  S..'...K.......N
00000840: 5815 1350 79e6 a215 761e 7203 6b40 0895  X..Py...v.r.k@..
00000850: ec19 ef8e 7d5f b0ce 9d63 cc5f eb80 8d6e  ....}_...c._...n
00000860: 5e97 421a 5b14 a24e d420 ef48 f623 67d7  ^.B.[..N. .H.#g.
00000870: fa3d b38b 7799 a166 998f 5d28 c232 e1b0  .=..w..f..](.2..
00000880: f535 ce92 e748 c346 b7e8 c3c2 ce1c 24e2  .5...H.F......$.
00000890: de8f 2297 9804 71fe 9a47 8e28 8538 6448  .."...q..G.(.8dH
000008a0: 8a68 6972 1162 41ec 754a 8988 9819 b2a3  .hir.bA.uJ......
000008b0: 58dd 73f1 d96f 29be 320e 929d b8db d7c7  X.s..o).2.......
000008c0: 51fa 5edf 94cd d9cf 9c77 ca91 1eeb 13d6  Q.^......w......
000008d0: 1a3e 9226 4eb2 d619 4f0f 52f5 0df4 1751  .>.&N...O.R....Q
000008e0: 82d5 a983 b828 2f26 87f6 ff9e 5dbc fe44  .....(/&....]..D
000008f0: 6168 9708 4a6e 1cf4 7827 c4bd c52e 4e6e  ah..Jn..x'....Nn
00000900: 6b6a cdf6 f0f2 9a9e 8d09 d23a 6039 2234  kj.........:`9"4
00000910: f009 0890 0d7b 517d ded4 14cb b7ea 17b4  .....{Q}........
00000920: cc0a 7e2a 0e0c d1ac 2edc 5a48 4450 5d4f  ..~*......ZHDP]O
00000930: 7ce0 ccf7 2824 a6c8 7fab 5988 9ec0 6e52  |...($....Y...nR
00000940: fa03 17c0 00a8 1048 f9e3 eea4 4440 a31a  .......H....D@..
00000950: 76cc 2ca7 3de3 e26b 716a e79f 5d37 2d27  v.,.=..kqj..]7-'
00000960: f6ab 6010 40a1 4882 b673 2635 38e1 0213  ..`.@.H..s&58...
00000970: f6d9 5990 4b70 2d35 7ac6 8069 69f0 2f2a  ..Y.Kp-5z..ii./*
00000980: 8914 2c97 c9ef 9b2a 11cf b655 1a45 34df  ..,....*...U.E4.
00000990: 5d19 7906 a343 bc58 af1b 2ee0 f4d4 3357  ].y..C.X......3W
000009a0: df2e be00 8c89 c5d1 8cf2 62b1 957e d8eb  ..........b..~..
000009b0: 6cab 4013 992b dba7 5bc9 eb97 5fcb 8eb5  l.@..+..[..._...
000009c0: cf7b 4c70 68f4 d37e dda2 99cb 0e1b f22e  .{Lph..~........
000009d0: 44ba 5e7d bda1 2535 76e3 4919 46b0 8b39  D.^}..%5v.I.F..9
000009e0: 05ea 3ced b8f3 c092 697b 5aa6 07b1 c939  ..<.....i{Z....9
000009f0: 6510 5ec8 d43b efa9 4e85 1161 5ebf 08b7  e.^..;..N..a^...
00000a00: e57d 349a 1558 5320 eb89 33f5 b0ff 9a2a  .}4..XS ..3....*
00000a10: 8543 ab6d 991c d97f 9730 7fa3 34da 1bb8  .C.m.....0..4...
00000a20: b09a fd74 ee76 fd6d 2189 2eaf 7f41 4df8  ...t.v.m!....AM.
00000a30: 98da e6ed 5b65 32d7 657c a76b debd 2289  ....[e2.e|.k..".
00000a40: a723 d968 d56e bd47 c715 4238 de59 49de  .#.h.n.G..B8.YI.
00000a50: c196 777a 42bc 7b0c 821e 2946 2bbe 3258  ..wzB.{...)F+.2X
00000a60: d331 f6b3 ebb1 0c2b 7ab6 9128 a1d2 ac58  .1.....+z..(...X
00000a70: 393a 9382 a987 0b9e 1ba6 ae90 68c6 e833  9:..........h..3
00000a80: ba09 970a 94c8 4a46 4c58 ec9d a0ce 7609  ......JFLX....v.
00000a90: 7b7d 74b8 c8cd c280 3531 92d1 ef69 d023  {}t.....51...i.#
00000aa0: bdab 86ef 19da 33eb e0cd ff8e 5ce6 19e8  ......3.....\...
00000ab0: d8ab 80d4 0ca1 d961 8ad4 1dec efad fd70  .......a.......p
00000ac0: e4cc 7f22 2a2f af47 d626 067d 4718 6dda  ..."*/.G.&.}G.m.
00000ad0: 4493 17d5 4eae 27d1 c571 4e37 fd6f ab3f  D...N.'..qN7.o.?
00000ae0: 3134 e103 0f16 5bcf dbed b8aa 921b 89a7  14....[.........
00000af0: 38bf 28f8 7643 233b 68ee da09 3129 b1ac  8.(.vC#;h...1)..
00000b00: ecf0 015b 8767 1a89 412a adce 2ad2 0664  ...[.g..A*..*..d
00000b10: d516 64e3 508b 7b9d 00d4 f4b8 7c67 4eab  ..d.P.{.....|gN.
00000b20: 9bb4 07a8 6f66 fff6 3f2b 5e62 add6 8bef  ....of..?+^b....
00000b30: 29b0 8573 ee3b 7b81 adac ec92 bc56 0de7  )..s.;{......V..
00000b40: 4847 00e7 b4b7 66fd 620b eed4 a9f2 534a  HG....f.b.....SJ
00000b50: cb64 3355 6e6f 3629 dfc0 031b b530 d6ab  .d3Uno6).....0..
00000b60: 561e 6c19 dcde 67e9 da99 5894 009f 7941  V.l...g...X...yA
00000b70: 6233 e658 6e21 dc3f f858 85b7 c834 1d08  b3.Xn!.?.X...4..
00000b80: bc70 85a4 0f70 a8d5 6092 4709 ab52 2a90  .p...p..`.G..R*.
00000b90: ca4b 821e 3cff 6c93 72c1 1478 5859 6a99  .K..<.l.r..xXYj.
00000ba0: 5ba9 e146 5473 1eb9 1d5e 4faa 6cfa 3ce1  [..FTs...^O.l.<.
00000bb0: a87d df55 9d8a d2f6 7f38 d414 70a8 eaea  .}.U.....8..p...
00000bc0: e7ff e024 608d f6d5 eb0f 54de 643a f609  ...$`.....T.d:..
00000bd0: fbe5 be5c f667 5a68 23c1 f32b dd19 1136  ...\.gZh#..+...6
00000be0: a4e3 6852 ea45 c861 b663 b3ac 3f77 225c  ..hR.E.a.c..?w"\
00000bf0: 7149 13f5 ddec 0933 36ca 1c5f 1270 9d28  qI.....36.._.p.(
00000c00: 3451 6e43 c375 88ee bc12 eb46 987d af59  4QnC.u.....F.}.Y
00000c10: 7151 0541 49ea bf5b a340 765f e9af 9fe5  qQ.AI..[.@v_....
00000c20: 6c66 714b fa0b cc4f 51ac d473 398b 9790  lfqK...OQ..s9...
00000c30: 4e4e 84ba 31e7 c65e 9d98 b4c7 fe59 911e  NN..1..^.....Y..
00000c40: 9722 720e 24f3 47cc e06c 29ce 2b5c 8597  ."r.$.G..l).+\..
00000c50: 11b5 bd9b a10c 6d43 d89f 44d0 0440 bdc6  ......mC..D..@..
00000c60: 333a 5d47 5262 90da f39d 8e29 e9b1 1f8a  3:]GRb.....)....
00000c70: d42e 7649 2d67 4049 ec2f aeb2 40c2 4d9b  ..vI-g@I./..@.M.
00000c80: 1663 51df bfe8 058d 51f9 8ff5 8810 41e7  .cQ.....Q.....A.
00000c90: e588 d964 74c1 c099 9cfa 2353 b2bb 922e  ...dt.....#S....
00000ca0: b92e 027a 1989 c8fc 6f41 7ada 315b 7e88  ...z....oAz.1[~.
00000cb0: 9a37 42f6 3100 e63e 4c18 f1ff 2865 acdd  .7B.1..>L...(e..
00000cc0: 92ac cb80 295e 3033 b5a9 1bb0 280f cd1a  ....)^03....(...
00000cd0: 1655 e5f7 cfad 1b9b ce48 95ac 32de 9707  .U.......H..2...
00000ce0: 144a e5cd 5543 8c1a 36e3 6962 b71e 0920  .J..UC..6.ib...
00000cf0: 5b5d 2d6b d443 3fc5 aae2 194b 347b d1be  []-k.C?....K4{..
00000d00: 7942 c21a 1d6c 8809 6815 369e 81b4 4f9a  yB...l..h.6...O.
00000d10: a6f0 00b9 865f 2f96 96c4 30fe 0156 e5e2  ....._/...0..V..
00000d20: 7714 7631 d4ea 52b8 00ad 6b9f 3524 021b  w.v1..R...k.5$..
00000d30: 22b6 8854 220d 8354 9661 6021 6dd0 aa2d  "..T"..T.a`!m..-
00000d40: d867 b025 5050 df49 f133 5d73 8972 e3c9  .g.%PP.I.3]s.r..
00000d50: d71f 75a8 a98e 81d7 41bb 5c46 a695 5551  ..u.....A.\F..UQ
00000d60: cb86 8f88 7f07 ff43 e556 3916 8f13 dee4  .......C.V9.....
00000d70: 1aba 3f1d ba66 31db 7ddd 0ac4 b70a 161f  ..?..f1.}.......
00000d80: 1d05 d3d2 50bd 81ac e407 b33f 53ad dc38  ....P......?S..8
00000d90: aca1 32c9 86db 7f79 48f2 739a 8570 40ca  ..2....yH.s..p@.
00000da0: ba34 f58c 5835 32b6 8dbf fa76 ffd0 5a4f  .4..X52....v..ZO
00000db0: 754e 0fe5 4eb9 32e8 7fc2 7ac3 809d f31f  uN..N.2...z.....
00000dc0: 8842 51b1 2292 63f0 5fee 88ed 2469 f037  .BQ.".c._...$i.7
00000dd0: 2455 bcf7 14e7 015e 0b18 3b53 567e 368a  $U.....^..;SV~6.
00000de0: 1a43 e4a9 573d fe7e 02e3 6331 72ee 3b57  .C..W=.~..c1r.;W
00000df0: fb9d 9ef0 e8b3 7918 1a31 194f 3ada e832  ......y..1.O:..2
00000e00: 6873 c285 a1ab 9f4f 518d 7c95 bf08 11df  hs.....OQ.|.....
00000e10: 350b 7a64 ba4e 2976 1039 4849 2114 00c3  5.zd.N)v.9HI!...
00000e20: dc37 1ba9 7185 bd00 8241 a6dc 4986 6437  .7..q....A..I.d7
00000e30: ba0a f85c bdef 48a9 74c0 a026 0acf 552f  ...\..H.t..&..U/
00000e40: af42 3416 2515 e18c e749 c83d 5db7 28ab  .B4.%....I.=].(.
00000e50: c17e 9b64 fd6a 1c6e f9d7 4414 0bd1 e24d  .~.d.j.n..D....M
00000e60: 98fc 54da 30ef eea8 898b 2d39 7f4d 237a  ..T.0.....-9.M#z
00000e70: df79 d53d e259 39de e6a9 7c6e ca18 2b70  .y.=.Y9...|n..+p
00000e80: 3fab 8b06 f7ab 9435 e58f 9b37 6cec 117d  ?......5...7l..}
00000e90: e0dc 7ab5 8537 d50c 2d3a ccfb 4710 7343  ..z..7..-:..G.sC
00000ea0: 9508 1254 eb53 b489 ec8d 1261 2431 9937  ...T.S.....a$1.7
00000eb0: 2be9 f58c a057 fadb aec1 f6e6 f25c b375  +....W.......\.u
00000ec0: ec8c e3a2 92e9 f3e0 dd2b 7d81 24c6 828c  .........+}.$...
00000ed0: 22af 595d 0549 fffb 3031 2a6a 62e6 3f98  ".Y].I..01*jb.?.
00000ee0: 349e 68cb 7be1 0d6d fc5a 1a80 e929 9f31  4.h.{..m.Z...).1
00000ef0: 4268 e49f 3190 a33a 1138 eace a932 beca  Bh..1..:.8...2..
00000f00: d64c f7f1 5953 8616 fceb ee7c c4c5 1107  .L..YS.....|....
00000f10: 97e6 c497 b8e3 1f6f fc07 67a3 50b9 bec1  .......o..g.P...
00000f20: 6acf fbdd 5fde 38f2 3b21 fadd a76a d362  j..._.8.;!...j.b
00000f30: 9b50 8e59 36c3 141a f125 bc9d 7e40 c993  .P.Y6....%..~@..
00000f40: 8902 2587 8dd4 e17f 3590 6e14 5464 8cac  ..%.....5.n.Td..
00000f50: 328e 2b54 1b05 4334 f01e 8e4a cb0d f3e9  2.+T..C4...J....
00000f60: 2f5a 265b 801a 8210 8e48 27de 3f95 1cc5  /Z&[.....H'.?...
00000f70: 99ba d7ab 3cfc 9456 a3b7 15f1 1319 8979  ....<..V.......y
00000f80: 61d8 6fe5 a05d 133a 4041 4b89 5e2d ece9  a.o..].:@AK.^-..
00000f90: ea9e dead f368 6aea 3d98 e183 38c3 d24e  .....hj.=...8..N
00000fa0: 7af9 07c1 824c 9825 08a4 b43a 0baa 1b47  z....L.%...:...G
00000fb0: ad55 7586 87c2 d069 709d 3dc0 1600 fbe3  .Uu....ip.=.....
00000fc0: 9ded 335b 3ba8 ccfc e65b 937e 5920 1362  ..3[;....[.~Y .b
00000fd0: 4838 9d79 d7ca 246c 281c e3fd d5a5 f0dd  H8.y..$l(.......
00000fe0: 6701 3144 4115 c69f b5f2 582f 14fe d5bb  g.1DA.....X/....
00000ff0: 8d63 b05c 87e2 3598 0663 10b4 55de 84a1  .c.\..5..c..U...
00001000: 6ac1 7260 18b3 90b6 687d c1d6 487f 8e23  j.r`....h}..H..#
00001010: 4151 5515 f20e e362 898c b557 a396 a0b4  AQU....b...W....
00001020: 4bb0 e3d3 24a6 7a88 6086 0af3 38b3 869d  K...$.z.`...8...
00001030: fd2c 47b1 a0fd b05a 620c 6acb 8ff9 4db5  .,G....Zb.j...M.
00001040: 4af3 34a0 5b76 3520 836f 79e7 fe4b 4ded  J.4.[v5 .oy..KM.
00001050: 93ba 0b19 b548 113d 1215 9052 c1e8 8380  .....H.=...R....
00001060: 413c 2e27 7500 cfe5 5562 36e1 7fd7 b03c  A<.'u...Ub6....<
00001070: 400d 93f7 7ab5 cd02 aa91 57ba e4a7 6443  @...z.....W...dC
00001080: 6465 03df 7d71 3479 0820 62de dafc 5a7d  de..}q4y. b...Z}
00001090: 9027 7bb8 836c 3b63 7d3e 65e9 d1db 6b27  .'{..l;c}>e...k'
000010a0: 59a0 7a03 297f 8ed3 70b8 f280 9bcc 9fb8  Y.z.)...p.......
000010b0: 7cd5 d054 fc3b daf5 9140 77b1 95a2 3c14  |..T.;...@w...<.
000010c0: e7aa a831 5e76 bf6d bf30 e023 3356 23a2  ...1^v.m.0.#3V#.
000010d0: 0c3a a75f fdfc b656 8c62 468d 0000 0000  .:._...V.bF.....
000010e0: 0000 0000 0000 0010 008e 7215 b000 6172  ..........r...ar
000010f0: 71d4 2a06 5402 101d 208b c139 0480 f70d  q.*.T... ..9....
00001100: a600 4175 a915 27ec d226 6608 a05a 8d62  ..Au..'..&f..Z.b
00001110: a601 daad b4fb 2680 04                   ......&..

Extracting the compressed data and piping into the tar command yields the desired results:

❯ zstdcat *.tzst | tar --list
.archinfo
tmp1bYRFK.tmp

I'll include the files here, too. The .bin is just the .tzst repackaged as a sanity check that the file command is reporting correctly.

TestCompressDirectory_ZstCompressedTar_FileInRoot.bin.txt
TestCompressDirectory_ZstCompressedTar_FileInRoot.tar.txt
TestCompressDirectory_ZstCompressedTar_FileInRoot.tzst.txt

Am I missing something, or have I stumbled on a bug?

Originally created by @SimonCahill on GitHub (Jul 14, 2025). It's been a while since I've actively used this library, but I'd had good experiences in the past, so I decided to use it once more. I have the following test case: ```cs [TestMethod] public async Task TestCompressDirectory_ZstCompressedTar_FileInRoot() { var tmpFile = Path.GetTempFileName(); var fileBytes = GenerateRandomMemory(4096); File.WriteAllBytes(tmpFile, fileBytes.ToArray()); var tmpPath = new DirectoryInfo(Path.Combine(Path.GetTempPath(), "HermodTests", "EmailArchiverTests", nameof(TestCompressDirectory_ZstCompressedTar_FileInRoot))); tmpPath.Create(); File.Move(tmpFile, Path.Combine(tmpPath.FullName, Path.GetFileName(tmpFile))); await m_emailArchiver.CompressDirectoryAsync(tmpPath, CompressionType.Squeezed); var expectedPath = Path.Combine(tmpPath.Parent?.FullName ?? string.Empty, $"{nameof(TestCompressDirectory_ZstCompressedTar_FileInRoot)}.tzst"); Assert.IsTrue(File.Exists(expectedPath), $"Archive file ({expectedPath}) was not created."); using var fStream = File.OpenRead(expectedPath); if (fStream.Length < 512) { // This is likely not a valid Zstandard compressed file. Assert.Fail($"Archive file ({expectedPath}) is not a valid Zstandard compressed file."); } Assert.IsTrue(VerifyTarHeader(), $"Archive file ({expectedPath}) is not a valid TAR file after decompression."); fStream.Seek(0, SeekOrigin.Begin); using var zstDecompStream = new DecompressionStream(fStream); using var tarArchive = TarArchive.Open(zstDecompStream); var entries = tarArchive.Entries.ToList(); // HERE! Assert.IsTrue(entries.Any(), $"Archive file ({expectedPath}) is empty."); bool VerifyTarHeader() { using var zstDecompStream = new DecompressionStream(fStream); Assert.IsTrue(zstDecompStream.CanRead, $"Archive file ({expectedPath}) is not a valid Zstandard compressed stream."); return TarArchive.IsTarFile(zstDecompStream); } } ``` Interestingly, it fails to detect the tar header in the marked line. The `VerifyTarHeader` method works as expected and doesn't throw. Checking the debugger, I get the following information: <img width="881" height="510" alt="Image" src="https://github.com/user-attachments/assets/463f750d-fcbf-4066-8da4-ef7e7715eeb7" /> ``` at SharpCompress.Archives.Tar.TarArchive.<LoadEntries>d__11.MoveNext() at SharpCompress.Helpers.LazyReadOnlyCollection`1.LazyLoader.MoveNext() at SharpCompress.Helpers.Utility.ForEach[T](IEnumerable`1 items, Action`1 action) at SharpCompress.Helpers.LazyReadOnlyCollection`1.EnsureFullyLoaded() at SharpCompress.Archives.AbstractArchive`2.SharpCompress.Archives.IArchiveExtractionListener.EnsureEntriesLoaded() at SharpCompress.Archives.AbstractArchive`2.get_IsComplete() ``` Below is a hex dump of the zst file: ``` 00000000: 28b5 2ffd 0058 8588 00bc 0d01 2e61 7263 (./..X.......arc 00000010: 6869 6e66 6f00 2020 2020 3737 3720 2030 hinfo. 777 0 00000020: 2020 3233 3400 3135 3033 3532 3534 3635 234.1503525465 00000030: 3200 2020 2035 3531 3420 4845 524d 4f44 2. 5514 HERMOD 00000040: 0000 0098 0100 0000 1095 6f75 5f41 1a86 ..........ou_A.. 00000050: 4d95 9fbe c2fe ef1c bd00 0000 20f7 1fae M........... ... 00000060: d45b 80e6 eace e16a 62ec eabf 79ce d1ad .[.....jb...y... 00000070: 9b6d 1a81 0622 714d 3c9b 9c52 a900 0000 .m..."qM<..R.... 00000080: 552f 746d 702f 4865 726d 6f64 5465 7374 U/tmp/HermodTest 00000090: 732f 456d 6169 6c41 7263 6869 7665 7254 s/EmailArchiverT 000000a0: 6573 7443 6f6d 7072 6573 7344 6972 6563 estCompressDirec 000000b0: 746f 7279 5f5a 6564 5461 725f 4669 6c65 tory_ZedTar_File 000000c0: 496e 526f 6f74 746d 7031 6259 5246 4b2e InRoottmp1bYRFK. 000000d0: 746d 7031 3030 3030 3632 3133 b1f3 d49f tmp100006213.... 000000e0: 3ebf dee4 1b44 8743 e3f7 79b7 6df4 94bc >....D.C..y.m... 000000f0: bc55 f538 f52c a68f 0502 5841 707b 0963 .U.8.,....XAp{.c 00000100: 3525 d66e e113 5497 3af4 3406 2a22 4aea 5%.n..T.:.4.*"J. 00000110: 101b 2cb7 98aa c4b5 f0fe 0b60 a614 5df0 ..,........`..]. 00000120: c26c 8490 525a 50a7 1870 b3e3 fb02 e697 .l..RZP..p...... 00000130: 2bf6 8cc4 3c80 fdf6 6c37 5754 dcc8 9760 +...<...l7WT...` 00000140: 34ce 2011 c978 7dcf a4b3 54f3 ae13 8281 4. ..x}...T..... 00000150: 1fc3 aa82 1263 4761 337a b3cd 87b3 6c32 .....cGa3z....l2 00000160: 040b b64f a11d 90e9 c1ae 372d a9d8 4765 ...O......7-..Ge 00000170: bebd 1f0b 1709 a823 7055 4f98 2d4d cbfe .......#pUO.-M.. 00000180: 7f4b 38fb 520a df3b d4a8 2ea6 2c51 704d .K8.R..;....,QpM 00000190: 0aba 20dd 8608 dcf5 d3ad 50df d8ea 6853 .. .......P...hS 000001a0: 3311 0dbd cf01 d2b6 9f3a b51f 659d db19 3........:..e... 000001b0: 7cfe 0ff7 83ab 5913 7d66 15e6 6a0e a207 |.....Y.}f..j... 000001c0: f0e4 3379 a10f 543c 0eec 80de 171b 1767 ..3y..T<.......g 000001d0: 39a6 9485 2671 0b66 f4a3 f3b9 425a 4489 9...&q.f....BZD. 000001e0: a681 9921 42e1 ed9b 5f46 7faa d64a 8a31 ...!B..._F...J.1 000001f0: dca0 d65d 4fc5 0056 cf71 19ee 0af8 3e56 ...]O..V.q....>V 00000200: a06b 9c18 76a0 3685 52a2 b9e8 5d10 0777 .k..v.6.R...]..w 00000210: 4274 4de5 bdfb ada8 b916 dd82 99a6 3f70 BtM...........?p 00000220: 6ed3 fc8e efec be0f b960 680a 3b25 8ba7 n........`h.;%.. 00000230: 13e8 344e 808a 0041 7293 74b3 9d09 6323 ..4N...Ar.t...c# 00000240: 8f25 b250 f124 9290 044d 34b3 45bb b644 .%.P.$...M4.E..D 00000250: 255c 405e 14ac 3287 f157 f701 d105 efcc %\@^..2..W...... 00000260: 3502 b133 0637 91e5 dc36 d3c8 530a 3adb 5..3.7...6..S.:. 00000270: 975a 8230 d1f8 c318 c481 a67a a455 56c5 .Z.0.......z.UV. 00000280: c77d f9b2 9b8b 823d abeb c5d0 0234 73cf .}.....=.....4s. 00000290: 21dc 053c 9219 0510 e09c 7ce3 9bbe ef3e !..<......|....> 000002a0: 705c f485 191b 4421 cfbd e7cf b405 60f6 p\....D!......`. 000002b0: a355 856f 5f91 aa7f a702 66d2 b599 f41a .U.o_.....f..... 000002c0: 925a 08e9 b946 d6c7 fe30 2e4b 2a6b 2438 .Z...F...0.K*k$8 000002d0: 99d4 da3c 40e0 1f95 09ea a7fb edae 3405 ...<@.........4. 000002e0: 1eee f2cb c4bc 2369 25cb aabf 5627 a9d5 ......#i%...V'.. 000002f0: 148b 3ebe 84ae 3bf8 5707 1ca0 1a86 e4e7 ..>...;.W....... 00000300: 6adb 19b2 0a64 41dd ff2e b9c6 d860 927a j....dA......`.z 00000310: 53ee ef81 4b8e 4904 55e8 e429 c753 6085 S...K.I.U..).S`. 00000320: 7aac d302 4588 512a c6a0 0416 49cd 335e z...E.Q*....I.3^ 00000330: 9ae0 1ca0 8ffd 226c e35f 7536 c742 7060 ......"l._u6.Bp` 00000340: 0b6a 2231 a981 8082 b27a 6f28 c082 a569 .j"1.....zo(...i 00000350: 1653 c34c 21b8 8ede dbd8 dd8a 79e3 94a7 .S.L!.......y... 00000360: cc38 aab6 4f71 e9df 7f7a f0ef cdf2 0a9e .8..Oq...z...... 00000370: 3784 bed9 92b1 bc6b 6334 5099 10b8 5611 7......kc4P...V. 00000380: 4a95 d439 dc5c 344c cd4e 6bef 3542 fa7f J..9.\4L.Nk.5B.. 00000390: 81bc fee4 2c1a 65e0 d906 83d4 cc50 5a06 ....,.e......PZ. 000003a0: 6b19 7e34 2989 7f18 ea96 7c56 e785 4afd k.~4).....|V..J. 000003b0: f4c8 a8c5 34ed 43f7 d56c 4802 8195 b913 ....4.C..lH..... 000003c0: 92bf 241a 648c 10f9 d5d4 fdc5 7335 1938 ..$.d.......s5.8 000003d0: 0ee1 d2fb 091f 4416 2a9d 71f5 73da 1463 ......D.*.q.s..c 000003e0: bde9 3339 74d1 5ea6 9a5d 77b1 32e9 6e4c ..39t.^..]w.2.nL 000003f0: 034f f92d 1495 aa0b 4030 e49b 2f33 015e .O.-....@0../3.^ 00000400: c108 31d0 e12d 6820 a984 8974 4c18 0583 ..1..-h ...tL... 00000410: 0474 27c8 1724 ffe6 1ba4 73f4 be22 656c .t'..$....s.."el 00000420: 544d ba04 80d4 4fdf 474f 1c73 93d3 7a66 TM....O.GO.s..zf 00000430: 3213 17ff de7f 8db1 01bb d9fe c068 acd3 2............h.. 00000440: 2744 88da e04e 9ac8 17e9 0f19 fccf e45a 'D...N.........Z 00000450: e809 9e78 cc12 ad83 f69a ac25 4c72 0753 ...x.......%Lr.S 00000460: 6c0e 1a73 67d8 0c1d 420b 9af9 6dc4 99a8 l..sg...B...m... 00000470: 7c9c 36fb 4ed8 b87b 004a 2ceb b3c4 7ab8 |.6.N..{.J,...z. 00000480: 7af1 c28b 849b 2181 b039 8ce1 0e0d c745 z.....!..9.....E 00000490: 8644 b58b 24b8 d79e 283a 6652 1021 fc42 .D..$...(:fR.!.B 000004a0: b374 94c2 6a6a 01a5 95c9 fad8 a407 4630 .t..jj........F0 000004b0: 521a f782 804a b804 35ef 3f37 5b02 282f R....J..5.?7[.(/ 000004c0: c9c6 adec cc91 c40f 07d5 3e48 7b75 ef78 ..........>H{u.x 000004d0: 5c0e 2b2b 48b7 1f21 c7d9 ee72 e9e3 e073 \.++H..!...r...s 000004e0: ef57 116a e6bd 4454 1fa7 0841 f518 2c78 .W.j..DT...A..,x 000004f0: 514b cd5e 9fc4 0dc0 73f3 5f30 70e2 1ab2 QK.^....s._0p... 00000500: 3fb7 0a38 eaec b7f2 068d fc0d 3e80 a421 ?..8........>..! 00000510: 344f b5f3 ca68 467c f2cc 0c14 df52 c1b2 4O...hF|.....R.. 00000520: faf2 5117 98bf 85bc 47ae b2ef 438c 2886 ..Q.....G...C.(. 00000530: 3988 b669 413a 1420 758f cd11 6a52 4be6 9..iA:. u...jRK. 00000540: 53c8 381f 30af 69ac de13 93be 2ce6 31cc S.8.0.i.....,.1. 00000550: a394 fcec 9948 1dd7 5e54 dfb2 503e 7208 .....H..^T..P>r. 00000560: 007b 2361 535e a76f 7c06 88f7 4e27 aff5 .{#aS^.o|...N'.. 00000570: 5935 fa5f 0c9d 2981 4c3e 2afc 94fe 6805 Y5._..).L>*...h. 00000580: 2f1e d984 0a3b 2f74 6047 339e 1537 e533 /....;/t`G3..7.3 00000590: d4a5 ed93 2dac 091c b9f7 bac5 0802 e5f5 ....-........... 000005a0: b5fe be19 052d ae34 4360 c077 4b4c 9db1 .....-.4C`.wKL.. 000005b0: e66e 2366 2e6b 570f f7d2 4498 3388 b3e1 .n#f.kW...D.3... 000005c0: 1d92 40c9 fa41 ff23 622e 7d81 acdd 5d96 ..@..A.#b.}...]. 000005d0: c778 1827 5528 082d 291e 9a59 a2a2 95dd .x.'U(.-)..Y.... 000005e0: 87a4 b761 af3c 76d2 6305 ed60 e51f 4529 ...a.<v.c..`..E) 000005f0: 4cd6 4ca2 d738 0cb8 4b63 6a93 da2d 657c L.L..8..Kcj..-e| 00000600: 44e2 238d b3b9 7d0d 0eb3 aa76 5819 0b1e D.#...}....vX... 00000610: fa44 0f8e 7432 89b3 c81e 597a 9071 911a .D..t2....Yz.q.. 00000620: a675 24e6 48e0 7923 38e8 4291 5883 2c08 .u$.H.y#8.B.X.,. 00000630: 141e 1fbc 3963 62b2 6148 1a7a 44f6 2e68 ....9cb.aH.zD..h 00000640: c1b9 23ac c50f d8a9 c1ca 259b a93e 0d15 ..#.......%..>.. 00000650: 8991 b292 9b07 704d ea90 f372 c794 ad3d ......pM...r...= 00000660: 7106 a23d 7245 d049 ac17 1810 58af af20 q..=rE.I....X.. 00000670: c5eb 8e97 488f 9409 4f5c 1555 9d51 8fba ....H...O\.U.Q.. 00000680: 8600 d51c 48e5 3485 f8a7 d953 8eef 5477 ....H.4....S..Tw 00000690: 5fc5 f88f 4824 c265 3bf2 456a 99b3 0ae4 _...H$.e;.Ej.... 000006a0: b6f1 8812 4510 dc34 3fd3 bb0e 0004 6987 ....E..4?.....i. 000006b0: 8e2c fdf6 9900 d33f 01a2 442d c7be 5a5c .,.....?..D-..Z\ 000006c0: 5980 4ba9 2387 6ec9 efe1 905e c0ab d67f Y.K.#.n....^.... 000006d0: 740a 26f7 d897 7deb f023 3bf4 d1da 1dff t.&...}..#;..... 000006e0: f07e 7e9c 9700 07d3 f3f8 ff47 3305 2e2f .~~........G3../ 000006f0: b7fd 955d 0595 66e6 5598 09f2 8be8 a359 ...]..f.U......Y 00000700: 7c23 cd2a 872f f6b6 d24c 867c 5a7e 4249 |#.*./...L.|Z~BI 00000710: 46ce 9e8f 64bc b159 1864 571b e0d5 07d2 F...d..Y.dW..... 00000720: 6f2a 8371 f132 554f 19ed 1054 9d71 7edf o*.q.2UO...T.q~. 00000730: 496a b0e6 0638 d819 fe1d 7c30 ff5c 7385 Ij...8....|0.\s. 00000740: ea07 1804 484e d28f eeb1 a163 389d 9a2b ....HN.....c8..+ 00000750: b243 3af7 55a4 3421 ebe9 436f 216f 5587 .C:.U.4!..Co!oU. 00000760: b072 9328 b7d9 8389 10f7 1a2b dadc 72b6 .r.(.......+..r. 00000770: b864 3e3f 2895 2025 6c8f c279 7056 3a4e .d>?(. %l..ypV:N 00000780: efe0 1989 491c 22a8 8c9f c730 11d5 0745 ....I."....0...E 00000790: a7dd d496 a850 7d19 59a1 f132 69ab df08 .....P}.Y..2i... 000007a0: c258 7004 0ced 8100 f525 c67a c82e 4fa1 .Xp......%.z..O. 000007b0: c7d0 483a 34f3 9975 3906 f6cd b7ed 8ca2 ..H:4..u9....... 000007c0: 3d7d 7ae8 0d3d a0ca 18c0 fa58 0b42 6956 =}z..=.....X.BiV 000007d0: 301b f7de 25a4 9868 09a1 4eb4 01c6 f5ba 0...%..h..N..... 000007e0: 45d3 b901 38e0 725c a637 52c0 a9f3 0c9b E...8.r\.7R..... 000007f0: d60f 0f67 ecf5 dc08 a396 6997 28a0 3e60 ...g......i.(.>` 00000800: 06b2 a32f 52e5 62e6 8699 1914 9012 57f4 .../R.b.......W. 00000810: bc21 2425 4f4b 3e51 963f 2eb4 50c1 c9dd .!$%OK>Q.?..P... 00000820: 93f1 e76f 10f1 9562 3c1d 3a44 a96b c93e ...o...b<.:D.k.> 00000830: 5309 1f27 ed8f 824b 0db1 b91e e8a4 f64e S..'...K.......N 00000840: 5815 1350 79e6 a215 761e 7203 6b40 0895 X..Py...v.r.k@.. 00000850: ec19 ef8e 7d5f b0ce 9d63 cc5f eb80 8d6e ....}_...c._...n 00000860: 5e97 421a 5b14 a24e d420 ef48 f623 67d7 ^.B.[..N. .H.#g. 00000870: fa3d b38b 7799 a166 998f 5d28 c232 e1b0 .=..w..f..](.2.. 00000880: f535 ce92 e748 c346 b7e8 c3c2 ce1c 24e2 .5...H.F......$. 00000890: de8f 2297 9804 71fe 9a47 8e28 8538 6448 .."...q..G.(.8dH 000008a0: 8a68 6972 1162 41ec 754a 8988 9819 b2a3 .hir.bA.uJ...... 000008b0: 58dd 73f1 d96f 29be 320e 929d b8db d7c7 X.s..o).2....... 000008c0: 51fa 5edf 94cd d9cf 9c77 ca91 1eeb 13d6 Q.^......w...... 000008d0: 1a3e 9226 4eb2 d619 4f0f 52f5 0df4 1751 .>.&N...O.R....Q 000008e0: 82d5 a983 b828 2f26 87f6 ff9e 5dbc fe44 .....(/&....]..D 000008f0: 6168 9708 4a6e 1cf4 7827 c4bd c52e 4e6e ah..Jn..x'....Nn 00000900: 6b6a cdf6 f0f2 9a9e 8d09 d23a 6039 2234 kj.........:`9"4 00000910: f009 0890 0d7b 517d ded4 14cb b7ea 17b4 .....{Q}........ 00000920: cc0a 7e2a 0e0c d1ac 2edc 5a48 4450 5d4f ..~*......ZHDP]O 00000930: 7ce0 ccf7 2824 a6c8 7fab 5988 9ec0 6e52 |...($....Y...nR 00000940: fa03 17c0 00a8 1048 f9e3 eea4 4440 a31a .......H....D@.. 00000950: 76cc 2ca7 3de3 e26b 716a e79f 5d37 2d27 v.,.=..kqj..]7-' 00000960: f6ab 6010 40a1 4882 b673 2635 38e1 0213 ..`.@.H..s&58... 00000970: f6d9 5990 4b70 2d35 7ac6 8069 69f0 2f2a ..Y.Kp-5z..ii./* 00000980: 8914 2c97 c9ef 9b2a 11cf b655 1a45 34df ..,....*...U.E4. 00000990: 5d19 7906 a343 bc58 af1b 2ee0 f4d4 3357 ].y..C.X......3W 000009a0: df2e be00 8c89 c5d1 8cf2 62b1 957e d8eb ..........b..~.. 000009b0: 6cab 4013 992b dba7 5bc9 eb97 5fcb 8eb5 l.@..+..[..._... 000009c0: cf7b 4c70 68f4 d37e dda2 99cb 0e1b f22e .{Lph..~........ 000009d0: 44ba 5e7d bda1 2535 76e3 4919 46b0 8b39 D.^}..%5v.I.F..9 000009e0: 05ea 3ced b8f3 c092 697b 5aa6 07b1 c939 ..<.....i{Z....9 000009f0: 6510 5ec8 d43b efa9 4e85 1161 5ebf 08b7 e.^..;..N..a^... 00000a00: e57d 349a 1558 5320 eb89 33f5 b0ff 9a2a .}4..XS ..3....* 00000a10: 8543 ab6d 991c d97f 9730 7fa3 34da 1bb8 .C.m.....0..4... 00000a20: b09a fd74 ee76 fd6d 2189 2eaf 7f41 4df8 ...t.v.m!....AM. 00000a30: 98da e6ed 5b65 32d7 657c a76b debd 2289 ....[e2.e|.k..". 00000a40: a723 d968 d56e bd47 c715 4238 de59 49de .#.h.n.G..B8.YI. 00000a50: c196 777a 42bc 7b0c 821e 2946 2bbe 3258 ..wzB.{...)F+.2X 00000a60: d331 f6b3 ebb1 0c2b 7ab6 9128 a1d2 ac58 .1.....+z..(...X 00000a70: 393a 9382 a987 0b9e 1ba6 ae90 68c6 e833 9:..........h..3 00000a80: ba09 970a 94c8 4a46 4c58 ec9d a0ce 7609 ......JFLX....v. 00000a90: 7b7d 74b8 c8cd c280 3531 92d1 ef69 d023 {}t.....51...i.# 00000aa0: bdab 86ef 19da 33eb e0cd ff8e 5ce6 19e8 ......3.....\... 00000ab0: d8ab 80d4 0ca1 d961 8ad4 1dec efad fd70 .......a.......p 00000ac0: e4cc 7f22 2a2f af47 d626 067d 4718 6dda ..."*/.G.&.}G.m. 00000ad0: 4493 17d5 4eae 27d1 c571 4e37 fd6f ab3f D...N.'..qN7.o.? 00000ae0: 3134 e103 0f16 5bcf dbed b8aa 921b 89a7 14....[......... 00000af0: 38bf 28f8 7643 233b 68ee da09 3129 b1ac 8.(.vC#;h...1).. 00000b00: ecf0 015b 8767 1a89 412a adce 2ad2 0664 ...[.g..A*..*..d 00000b10: d516 64e3 508b 7b9d 00d4 f4b8 7c67 4eab ..d.P.{.....|gN. 00000b20: 9bb4 07a8 6f66 fff6 3f2b 5e62 add6 8bef ....of..?+^b.... 00000b30: 29b0 8573 ee3b 7b81 adac ec92 bc56 0de7 )..s.;{......V.. 00000b40: 4847 00e7 b4b7 66fd 620b eed4 a9f2 534a HG....f.b.....SJ 00000b50: cb64 3355 6e6f 3629 dfc0 031b b530 d6ab .d3Uno6).....0.. 00000b60: 561e 6c19 dcde 67e9 da99 5894 009f 7941 V.l...g...X...yA 00000b70: 6233 e658 6e21 dc3f f858 85b7 c834 1d08 b3.Xn!.?.X...4.. 00000b80: bc70 85a4 0f70 a8d5 6092 4709 ab52 2a90 .p...p..`.G..R*. 00000b90: ca4b 821e 3cff 6c93 72c1 1478 5859 6a99 .K..<.l.r..xXYj. 00000ba0: 5ba9 e146 5473 1eb9 1d5e 4faa 6cfa 3ce1 [..FTs...^O.l.<. 00000bb0: a87d df55 9d8a d2f6 7f38 d414 70a8 eaea .}.U.....8..p... 00000bc0: e7ff e024 608d f6d5 eb0f 54de 643a f609 ...$`.....T.d:.. 00000bd0: fbe5 be5c f667 5a68 23c1 f32b dd19 1136 ...\.gZh#..+...6 00000be0: a4e3 6852 ea45 c861 b663 b3ac 3f77 225c ..hR.E.a.c..?w"\ 00000bf0: 7149 13f5 ddec 0933 36ca 1c5f 1270 9d28 qI.....36.._.p.( 00000c00: 3451 6e43 c375 88ee bc12 eb46 987d af59 4QnC.u.....F.}.Y 00000c10: 7151 0541 49ea bf5b a340 765f e9af 9fe5 qQ.AI..[.@v_.... 00000c20: 6c66 714b fa0b cc4f 51ac d473 398b 9790 lfqK...OQ..s9... 00000c30: 4e4e 84ba 31e7 c65e 9d98 b4c7 fe59 911e NN..1..^.....Y.. 00000c40: 9722 720e 24f3 47cc e06c 29ce 2b5c 8597 ."r.$.G..l).+\.. 00000c50: 11b5 bd9b a10c 6d43 d89f 44d0 0440 bdc6 ......mC..D..@.. 00000c60: 333a 5d47 5262 90da f39d 8e29 e9b1 1f8a 3:]GRb.....).... 00000c70: d42e 7649 2d67 4049 ec2f aeb2 40c2 4d9b ..vI-g@I./..@.M. 00000c80: 1663 51df bfe8 058d 51f9 8ff5 8810 41e7 .cQ.....Q.....A. 00000c90: e588 d964 74c1 c099 9cfa 2353 b2bb 922e ...dt.....#S.... 00000ca0: b92e 027a 1989 c8fc 6f41 7ada 315b 7e88 ...z....oAz.1[~. 00000cb0: 9a37 42f6 3100 e63e 4c18 f1ff 2865 acdd .7B.1..>L...(e.. 00000cc0: 92ac cb80 295e 3033 b5a9 1bb0 280f cd1a ....)^03....(... 00000cd0: 1655 e5f7 cfad 1b9b ce48 95ac 32de 9707 .U.......H..2... 00000ce0: 144a e5cd 5543 8c1a 36e3 6962 b71e 0920 .J..UC..6.ib... 00000cf0: 5b5d 2d6b d443 3fc5 aae2 194b 347b d1be []-k.C?....K4{.. 00000d00: 7942 c21a 1d6c 8809 6815 369e 81b4 4f9a yB...l..h.6...O. 00000d10: a6f0 00b9 865f 2f96 96c4 30fe 0156 e5e2 ....._/...0..V.. 00000d20: 7714 7631 d4ea 52b8 00ad 6b9f 3524 021b w.v1..R...k.5$.. 00000d30: 22b6 8854 220d 8354 9661 6021 6dd0 aa2d "..T"..T.a`!m..- 00000d40: d867 b025 5050 df49 f133 5d73 8972 e3c9 .g.%PP.I.3]s.r.. 00000d50: d71f 75a8 a98e 81d7 41bb 5c46 a695 5551 ..u.....A.\F..UQ 00000d60: cb86 8f88 7f07 ff43 e556 3916 8f13 dee4 .......C.V9..... 00000d70: 1aba 3f1d ba66 31db 7ddd 0ac4 b70a 161f ..?..f1.}....... 00000d80: 1d05 d3d2 50bd 81ac e407 b33f 53ad dc38 ....P......?S..8 00000d90: aca1 32c9 86db 7f79 48f2 739a 8570 40ca ..2....yH.s..p@. 00000da0: ba34 f58c 5835 32b6 8dbf fa76 ffd0 5a4f .4..X52....v..ZO 00000db0: 754e 0fe5 4eb9 32e8 7fc2 7ac3 809d f31f uN..N.2...z..... 00000dc0: 8842 51b1 2292 63f0 5fee 88ed 2469 f037 .BQ.".c._...$i.7 00000dd0: 2455 bcf7 14e7 015e 0b18 3b53 567e 368a $U.....^..;SV~6. 00000de0: 1a43 e4a9 573d fe7e 02e3 6331 72ee 3b57 .C..W=.~..c1r.;W 00000df0: fb9d 9ef0 e8b3 7918 1a31 194f 3ada e832 ......y..1.O:..2 00000e00: 6873 c285 a1ab 9f4f 518d 7c95 bf08 11df hs.....OQ.|..... 00000e10: 350b 7a64 ba4e 2976 1039 4849 2114 00c3 5.zd.N)v.9HI!... 00000e20: dc37 1ba9 7185 bd00 8241 a6dc 4986 6437 .7..q....A..I.d7 00000e30: ba0a f85c bdef 48a9 74c0 a026 0acf 552f ...\..H.t..&..U/ 00000e40: af42 3416 2515 e18c e749 c83d 5db7 28ab .B4.%....I.=].(. 00000e50: c17e 9b64 fd6a 1c6e f9d7 4414 0bd1 e24d .~.d.j.n..D....M 00000e60: 98fc 54da 30ef eea8 898b 2d39 7f4d 237a ..T.0.....-9.M#z 00000e70: df79 d53d e259 39de e6a9 7c6e ca18 2b70 .y.=.Y9...|n..+p 00000e80: 3fab 8b06 f7ab 9435 e58f 9b37 6cec 117d ?......5...7l..} 00000e90: e0dc 7ab5 8537 d50c 2d3a ccfb 4710 7343 ..z..7..-:..G.sC 00000ea0: 9508 1254 eb53 b489 ec8d 1261 2431 9937 ...T.S.....a$1.7 00000eb0: 2be9 f58c a057 fadb aec1 f6e6 f25c b375 +....W.......\.u 00000ec0: ec8c e3a2 92e9 f3e0 dd2b 7d81 24c6 828c .........+}.$... 00000ed0: 22af 595d 0549 fffb 3031 2a6a 62e6 3f98 ".Y].I..01*jb.?. 00000ee0: 349e 68cb 7be1 0d6d fc5a 1a80 e929 9f31 4.h.{..m.Z...).1 00000ef0: 4268 e49f 3190 a33a 1138 eace a932 beca Bh..1..:.8...2.. 00000f00: d64c f7f1 5953 8616 fceb ee7c c4c5 1107 .L..YS.....|.... 00000f10: 97e6 c497 b8e3 1f6f fc07 67a3 50b9 bec1 .......o..g.P... 00000f20: 6acf fbdd 5fde 38f2 3b21 fadd a76a d362 j..._.8.;!...j.b 00000f30: 9b50 8e59 36c3 141a f125 bc9d 7e40 c993 .P.Y6....%..~@.. 00000f40: 8902 2587 8dd4 e17f 3590 6e14 5464 8cac ..%.....5.n.Td.. 00000f50: 328e 2b54 1b05 4334 f01e 8e4a cb0d f3e9 2.+T..C4...J.... 00000f60: 2f5a 265b 801a 8210 8e48 27de 3f95 1cc5 /Z&[.....H'.?... 00000f70: 99ba d7ab 3cfc 9456 a3b7 15f1 1319 8979 ....<..V.......y 00000f80: 61d8 6fe5 a05d 133a 4041 4b89 5e2d ece9 a.o..].:@AK.^-.. 00000f90: ea9e dead f368 6aea 3d98 e183 38c3 d24e .....hj.=...8..N 00000fa0: 7af9 07c1 824c 9825 08a4 b43a 0baa 1b47 z....L.%...:...G 00000fb0: ad55 7586 87c2 d069 709d 3dc0 1600 fbe3 .Uu....ip.=..... 00000fc0: 9ded 335b 3ba8 ccfc e65b 937e 5920 1362 ..3[;....[.~Y .b 00000fd0: 4838 9d79 d7ca 246c 281c e3fd d5a5 f0dd H8.y..$l(....... 00000fe0: 6701 3144 4115 c69f b5f2 582f 14fe d5bb g.1DA.....X/.... 00000ff0: 8d63 b05c 87e2 3598 0663 10b4 55de 84a1 .c.\..5..c..U... 00001000: 6ac1 7260 18b3 90b6 687d c1d6 487f 8e23 j.r`....h}..H..# 00001010: 4151 5515 f20e e362 898c b557 a396 a0b4 AQU....b...W.... 00001020: 4bb0 e3d3 24a6 7a88 6086 0af3 38b3 869d K...$.z.`...8... 00001030: fd2c 47b1 a0fd b05a 620c 6acb 8ff9 4db5 .,G....Zb.j...M. 00001040: 4af3 34a0 5b76 3520 836f 79e7 fe4b 4ded J.4.[v5 .oy..KM. 00001050: 93ba 0b19 b548 113d 1215 9052 c1e8 8380 .....H.=...R.... 00001060: 413c 2e27 7500 cfe5 5562 36e1 7fd7 b03c A<.'u...Ub6....< 00001070: 400d 93f7 7ab5 cd02 aa91 57ba e4a7 6443 @...z.....W...dC 00001080: 6465 03df 7d71 3479 0820 62de dafc 5a7d de..}q4y. b...Z} 00001090: 9027 7bb8 836c 3b63 7d3e 65e9 d1db 6b27 .'{..l;c}>e...k' 000010a0: 59a0 7a03 297f 8ed3 70b8 f280 9bcc 9fb8 Y.z.)...p....... 000010b0: 7cd5 d054 fc3b daf5 9140 77b1 95a2 3c14 |..T.;...@w...<. 000010c0: e7aa a831 5e76 bf6d bf30 e023 3356 23a2 ...1^v.m.0.#3V#. 000010d0: 0c3a a75f fdfc b656 8c62 468d 0000 0000 .:._...V.bF..... 000010e0: 0000 0000 0000 0010 008e 7215 b000 6172 ..........r...ar 000010f0: 71d4 2a06 5402 101d 208b c139 0480 f70d q.*.T... ..9.... 00001100: a600 4175 a915 27ec d226 6608 a05a 8d62 ..Au..'..&f..Z.b 00001110: a601 daad b4fb 2680 04 ......&.. ``` Extracting the compressed data and piping into the `tar` command yields the desired results: ``` ❯ zstdcat *.tzst | tar --list .archinfo tmp1bYRFK.tmp ``` I'll include the files here, too. The `.bin` is just the `.tzst` repackaged as a sanity check that the `file` command is reporting correctly. [TestCompressDirectory_ZstCompressedTar_FileInRoot.bin.txt](https://github.com/user-attachments/files/21221539/TestCompressDirectory_ZstCompressedTar_FileInRoot.bin.txt) [TestCompressDirectory_ZstCompressedTar_FileInRoot.tar.txt](https://github.com/user-attachments/files/21221541/TestCompressDirectory_ZstCompressedTar_FileInRoot.tar.txt) [TestCompressDirectory_ZstCompressedTar_FileInRoot.tzst.txt](https://github.com/user-attachments/files/21221540/TestCompressDirectory_ZstCompressedTar_FileInRoot.tzst.txt) Am I missing something, or have I stumbled on a bug?
claunia added the bugup for grabs labels 2026-01-29 22:16:01 +00:00
Author
Owner

@SimonCahill commented on GitHub (Jul 14, 2025):

This also happens with GZip-compressed archives. The test setup is virtually the same, except for the fact it uses GZip compression.

The file looks good everywhere else, but SharpCompress is (seemingly) having issues.

For completeness' sake, here's the compression code:

/// <summary>
/// Compresses the specified directory into a .tar archive.
/// </summary>
/// <param name="directory"></param>
/// <param name="compressionType"></param>
/// <returns></returns>
/// <exception cref="InvalidOperationException"></exception>
#if UNIT_TESTING
public
#else
private 
#endif // UNIT_TESTING
async Task CompressDirectoryAsync(DirectoryInfo directory, CompressionType compressionType = CompressionType.None) {
    if (directory is null) {
        throw new ArgumentNullException(nameof(directory), "The directory to compress cannot be null.");
    }

    if (!directory.Exists) {
        LogWarning($"The directory {directory.FullName} does not exist. Cannot compress a non-existing directory.");
        return;
    }

    await CloseArchiveAsync(directory);

    using var tarArchive = TarArchive.Create();

    tarArchive.AddAllFromDirectory(directory.FullName);
    var fileExtension = GetDirectoryArchiveFileExtensionForCompressionType(compressionType);
    var archiveFileName = $"{directory.Name}{fileExtension}";


    if (directory.Parent is null) {
        throw new InvalidOperationException("The directory does not have a parent directory to save the archive.");
    }

    var archiveFilePath = Path.Combine(directory.Parent.FullName, archiveFileName);

    using var fileStream = new FileStream(archiveFilePath, FileMode.Create);
    if (compressionType is not CompressionType.Squeezed) {
        tarArchive.SaveTo(fileStream, new TarWriterOptions(compressionType, true));
    } else {
        using var zstCompStream = new CompressionStream(fileStream);
        tarArchive.SaveTo(zstCompStream, new TarWriterOptions(CompressionType.None, true));
    }
}
@SimonCahill commented on GitHub (Jul 14, 2025): This also happens with GZip-compressed archives. The test setup is virtually the same, except for the fact it uses GZip compression. The file looks good everywhere else, but SharpCompress is (seemingly) having issues. For completeness' sake, here's the compression code: ```cs /// <summary> /// Compresses the specified directory into a .tar archive. /// </summary> /// <param name="directory"></param> /// <param name="compressionType"></param> /// <returns></returns> /// <exception cref="InvalidOperationException"></exception> #if UNIT_TESTING public #else private #endif // UNIT_TESTING async Task CompressDirectoryAsync(DirectoryInfo directory, CompressionType compressionType = CompressionType.None) { if (directory is null) { throw new ArgumentNullException(nameof(directory), "The directory to compress cannot be null."); } if (!directory.Exists) { LogWarning($"The directory {directory.FullName} does not exist. Cannot compress a non-existing directory."); return; } await CloseArchiveAsync(directory); using var tarArchive = TarArchive.Create(); tarArchive.AddAllFromDirectory(directory.FullName); var fileExtension = GetDirectoryArchiveFileExtensionForCompressionType(compressionType); var archiveFileName = $"{directory.Name}{fileExtension}"; if (directory.Parent is null) { throw new InvalidOperationException("The directory does not have a parent directory to save the archive."); } var archiveFilePath = Path.Combine(directory.Parent.FullName, archiveFileName); using var fileStream = new FileStream(archiveFilePath, FileMode.Create); if (compressionType is not CompressionType.Squeezed) { tarArchive.SaveTo(fileStream, new TarWriterOptions(compressionType, true)); } else { using var zstCompStream = new CompressionStream(fileStream); tarArchive.SaveTo(zstCompStream, new TarWriterOptions(CompressionType.None, true)); } } ```
Author
Owner

@SimonCahill commented on GitHub (Jul 15, 2025):

This doesn't happen when fully decompressing the stream into a MemoryStream before passing to TarArchive.

I'll pull the source and see if I can debug further.

@SimonCahill commented on GitHub (Jul 15, 2025): This doesn't happen when fully decompressing the stream into a `MemoryStream` before passing to `TarArchive`. I'll pull the source and see if I can debug further.
Author
Owner

@SimonCahill commented on GitHub (Jul 17, 2025):

At least with the zstd compression, I feel the base issue is the statefulness of the Zstd compression, meaning the zstDecompStream (DecompressionStream) cannot seek.
Would explain why copying it to a MemoryStream beforehand fixes the issue.

There may have to be a workaround when using zstd as the compression algo for streaming archives.

@SimonCahill commented on GitHub (Jul 17, 2025): At least with the zstd compression, I feel the base issue is the statefulness of the Zstd compression, meaning the zstDecompStream (`DecompressionStream`) cannot seek. Would explain why copying it to a MemoryStream beforehand fixes the issue. There may have to be a workaround when using zstd as the compression algo for streaming archives.
Author
Owner

@Morilli commented on GitHub (Jul 20, 2025):

The documentation for TarArchive.Open states "Takes a seekable Stream as a source". By passing in a non-seekable stream (the DecompressionStream), you're violating that condition and things fail.

Perhaps the method should throw if the input stream isn't seekable instead of falling over with an unidentifiable error later on?

@Morilli commented on GitHub (Jul 20, 2025): The documentation for [TarArchive.Open](https://github.com/adamhathcock/sharpcompress/blob/9483856439950fe8c5dcecebdc97be3bbeb6cb15/src/SharpCompress/Archives/Tar/TarArchive.cs#L90) states "Takes a seekable Stream as a source". By passing in a non-seekable stream (the DecompressionStream), you're violating that condition and things fail. Perhaps the method should throw if the input stream isn't seekable instead of falling over with an unidentifiable error later on?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#692