Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of symlinks extracted from zip files #39

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Revision history for Perl extension PGXN::API

0.20.2
- Fixed symlinks extracted from Zip files and permission errors when
re-indexing distributions.

0.20.1 2024-02-15T22:18:14Z
- Fixed a bug where a testing extension's version and abstract was not
Expand Down
16 changes: 11 additions & 5 deletions lib/PGXN/API/Sync.pm
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,20 @@ sub unzip {
make_path $dist_dir unless -e $dist_dir && -d _;

foreach my $member ($zip->members) {
# Make sure the file is readable by everyone
$member->unixFileAttributes( $member->isDirectory ? 0755 : 0444 );
my $fn = catfile $dist_dir, split m{/} => $member->fileName;
say " $fn\n" if $self->verbose > 2;

if ($member->isSymbolicLink) {
# Delete exsting so Archive::Zip won't fail to create it.
warn "Cannot unlink $fn: $!\n" if -e $fn && !unlink $fn;
} else {
# Make sure the member is readable by everyone.
$member->unixFileAttributes( $member->isDirectory ? 0755 : 0644 );
}

if ($member->extractToFileNamed($fn) != AZ_OK) {
warn "Error extracting $zip_path\n";
## XXX clean up the mess here.
return;
warn "Error extracting $fn from $zip_path\n";
next;
}
}

Expand Down
Loading