Skip to content

fix(archive,paste): make symlinks survive compress / extract / copy#352

Merged
lovehunter9 merged 1 commit into
mainfrom
archive_debug
Jun 17, 2026
Merged

fix(archive,paste): make symlinks survive compress / extract / copy#352
lovehunter9 merged 1 commit into
mainfrom
archive_debug

Conversation

@lovehunter9

Copy link
Copy Markdown
Collaborator

Summary

Make symbolic links behave sensibly across archive and copy operations:

  • Compress: directory symlinks are staged (via cp -a -l) so 7z stores them as links instead of erroring with errno=22; PreserveSymlinks now also applies to tar.gz/bz2/xz; when not preserving, sources are dereferenced; same-name sources are rejected up front with a clear message instead of a raw 7z "Duplicate filename" failure.
  • Extract: undo 7z's absolute-symlink confinement (it prepends the output dir to the target) so a preserved absolute link keeps its original target; and a symlink 7z refuses as "Dangerous link path" no longer fails the whole extract — the unsafe link is skipped and the rest extracts normally.
  • Copy: drop rsync --safe-links (it silently dropped absolute / out-of-tree links) and chown links with lchown (so a dangling link no longer ENOENTs); CheckPathExists now treats a dangling symlink as existing so it can be copied/extracted.

Notes

  • Tree-escaping symlinks are still confined by the tools' zip-slip protections; faithfully materializing them would require a read/share-side containment guard (tracked separately).

Test plan

  • Compress a folder containing a directory symlink with preserve on (zip / 7z / tar.gz) → succeeds, link stored.
  • Compress with two same-name sources → clear "would both be archived as" error.
  • Compress an absolute file symlink, extract → link keeps its original target.
  • Extract an archive whose only/one entry is an escaping symlink → no hard failure.
  • Copy a dangling symlink → no chown ENOENT, link copied.
  • Regression: normal files/folders compress, extract and copy unchanged.

Made with Cursor

Compress stages directory symlinks (preserve works for zip/7z/tar*) and rejects same-name sources; copy drops rsync --safe-links and chowns links via lchown; extract restores absolute-link targets and no longer fails on 7z's dangerous-link refusal. Dangling symlinks now count as existing for paste/extract source checks.

Co-authored-by: Cursor <cursoragent@cursor.com>
@lovehunter9 lovehunter9 merged commit 4aca51e into main Jun 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant