Commit Graph
10 Commits
Author SHA1 Message Date
Nigel Tao b2e6da3024 lib/suitar: allow implicitly-sized entries 2026-09-29 22:31:20 +10:00
Nigel Tao b1adeeccb1 lib/suitar: allow Write to a sparse entry 2026-09-15 15:31:04 +10:00
Nigel Tao b77e1a67de lib/suitar: make some Reader.Next errors sticky
Updates PR #179
2026-09-15 14:02:10 +10:00
Nigel Tao c944c491c4 lib/suitar: tweak some style nits
Updates PR #179
2026-09-15 14:00:21 +10:00
Nigel Tao 742e8b78d9 lib/suitar: reject names ending in "/." or "/.." 2026-09-15 10:42:51 +10:00
rootkiller6788 193d0354b4 lib/suitar: test chunked writes and directory entries
TestWriterChunked writes one file several times, splitting the contents
over Write calls differently each time, and checks the archive bytes come
out identical. The capped writer makes a runaway Write fail the test
instead of hanging it.

TestWriterDir writes a directory and then a file inside it, and reads
both back.
2026-09-12 23:48:25 +08:00
rootkiller6788 26ce8600a1 lib/suitar: let WriteHeader write a directory entry
WriteHeader copied h into w.header before calling w.Write to emit the
GNUTYPE_LONGNAME block holding the name. Write only accepts TypeReg and
TypeGNUSparse, so a TypeDir header failed that call and left the Writer
permanently in an error state - every later entry on the same Writer
failed too.

Set w.header after the name block has gone out instead.
2026-09-12 23:48:18 +08:00
rootkiller6788 05a8209fa7 lib/suitar: reset bIndex after flushing a full block
Write left w.bIndex at 512 once a full block had been written out, so the
next loop iteration took the "partial block" branch, copied zero bytes and
went round again forever, writing the same 512 bytes over and over. Calling
Write with sizes that aren't multiples of 512 is enough to hit this.

It also duplicated the last data block when a Write call happened to end
exactly on a block boundary, because flush then saw a non-zero bIndex and
wrote the block out a second time.
2026-09-12 23:48:01 +08:00
Nigel Tao 0f214ba59c lib/suitar: add trailing EOF blocks
Both /usr/bin/tar and the Go standard library don't seem to need this,
but some other TAR readers might expect it.
2026-09-03 08:31:06 +10:00
Nigel Tao 504f8485f4 lib/suitar: add new Go package
$ TZ=UTC tar -tvf test/data/archive.dense.suitar
-rw-r--r-- nobody/nobody     0 2020-02-05 06:10 artificial/0.bytes
-rw-r--r-- nobody/nobody   853 2020-08-12 14:04 github-tags.json
-rwxr-xr-x nobody/nobody   693 2021-05-03 06:19 hello.sh
-rw-r--r-- nobody/nobody   104 2021-05-03 06:16 non-ascii/αβ.txt
-rw-r--r-- nobody/nobody   151 2021-05-03 06:23 non-ascii/😻.txt
-rw-r--r-- nobody/nobody   208 2020-02-05 06:10 pjw-thumbnail.png
-rw-r--r-- nobody/nobody   942 2020-02-05 06:10 romeo.txt
-rw-r--r-- nobody/nobody   558 2020-02-05 06:10 romeo.txt.gz
2026-09-01 21:55:46 +10:00