Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions Sources/ZIPFoundation/FileManager+ZIP.swift
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,25 @@ extension FileManager {
throw Entry.EntryError.missingModificationDateAttributeError
}

try self.setSymlinkModificationDate(modificationDate, ofItemAtURL: url)
#elseif os(Linux)
// Permission bits on symlinks are ignored by the Linux kernel, so the
// archive's stored permissions for symlinks have nothing to attach to
// — `lchmod` is effectively a no-op even when Glibc exposes it. The
// modification date *is* respected though: `lutimes` writes to the
// symlink itself rather than its target, and Glibc has shipped it
// since 2.6. swift-corelibs-foundation's `setAttributes` doesn't
// round-trip `.modificationDate` for symlinks today, so we go
// straight to the libc syscall here to preserve mtime parity with
// Apple platforms when extracting.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good.
Can you please move the
testInvalidSymlinkCompressionMethodErrorConditions
testSymlinkModificationDateTransferErrorConditions
tests from the darwinOnlyTests to the allTests list. They are also relevant on Linux now.

guard let modificationDate = attributes[.modificationDate] as? Date else {
throw Entry.EntryError.missingModificationDateAttributeError
}

try self.setSymlinkModificationDate(modificationDate, ofItemAtURL: url)
#else
// Since non-Darwin POSIX platforms ignore permissions on symlinks and swift-corelibs-foundation
// currently doesn't support setting the modification date, this codepath is currently a no-op
// on these platforms.
// Bionic and Windows lack a fully equivalent symlink-targeted

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just say "Other platforms" here (vs. Windows & Bionic)

// `lutimes`; leave this codepath as a no-op there.
return
#endif
}
Expand Down
Loading