Thin archives: fix BSD long filenames and directory entries #196

Closed
opened 2026-04-11 19:45:12 +00:00 by fuzzy · 1 comment
Owner

Thin archive creation currently fails when filenames contain slashes (BSD long filename format) or for directory entries. The writer's padding logic and reader's handling need adjustment for these cases.

Symptoms: reptar -t -f archive.thin returns "unexpected EOF".

Need to investigate:

  1. BSD long filename handling in thin archives: filename data is written but padding may be incorrectly skipped.
  2. Directory entries with zero size should be handled.

Unit tests pass for simple cases (short filenames, regular files, symlinks).

Thin archive creation currently fails when filenames contain slashes (BSD long filename format) or for directory entries. The writer's padding logic and reader's handling need adjustment for these cases. Symptoms: `reptar -t -f archive.thin` returns "unexpected EOF". Need to investigate: 1. BSD long filename handling in thin archives: filename data is written but padding may be incorrectly skipped. 2. Directory entries with zero size should be handled. Unit tests pass for simple cases (short filenames, regular files, symlinks).
Author
Owner

Fixed in commit [TBD]. The root cause was:

  1. Padding logic: The writer's padToEven was incorrectly skipping padding for thin archives when the total entry size (including BSD long filename data) was odd. Fixed by always padding based on totalSize (which includes BSD long filename length).

  2. Reader handling: The reader's Next() method wasn't properly handling padding after BSD long filenames in thin archives. Added explicit skip of leftover data and padding.

  3. Metadata skip: The SkipInternalMeta global flag wasn't being respected in ensureMetaDir() and addMetaEntry(), causing metadata directory entries to be written even when --no-internal-meta was set.

All AR package tests now pass, including new tests TestThinArchiveBSDLongFilename and TestThinArchiveDirectory.

Thin archives with BSD long filenames and directory entries now work correctly.

Fixed in commit [TBD]. The root cause was: 1. **Padding logic**: The writer's `padToEven` was incorrectly skipping padding for thin archives when the total entry size (including BSD long filename data) was odd. Fixed by always padding based on `totalSize` (which includes BSD long filename length). 2. **Reader handling**: The reader's `Next()` method wasn't properly handling padding after BSD long filenames in thin archives. Added explicit skip of leftover data and padding. 3. **Metadata skip**: The `SkipInternalMeta` global flag wasn't being respected in `ensureMetaDir()` and `addMetaEntry()`, causing metadata directory entries to be written even when `--no-internal-meta` was set. All AR package tests now pass, including new tests `TestThinArchiveBSDLongFilename` and `TestThinArchiveDirectory`. Thin archives with BSD long filenames and directory entries now work correctly.
fuzzy closed this issue 2026-04-12 04:37:56 +00:00
Sign in to join this conversation.
No description provided.