Skip to content

Commit

Permalink
Fix(Task/Ext/Archive/ZipTask): Preseves directories' permissions in zip
Browse files Browse the repository at this point in the history
Fix phingofficial#1817 When file permissions are supported, stores directories's original
permissions as `ZipArchive::OPSYS_UNIX` `ExternalAttribute`.
  • Loading branch information
leagris committed Apr 28, 2024
1 parent dc73953 commit dad96cc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Phing/Task/Ext/Archive/ZipTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,12 @@ private function addFilesetsToArchive($zip)
if ($f->isDirectory()) {
if ($pathInZip != '.') {
$zip->addEmptyDir($pathInZip);
$filePerms = fileperms($f->getPath());
if (false !== $filePerms) { // filePerms supported
$dirAttrs = $filePerms << 16;
$dirAttrName = $pathInZip . '/';
$zip->setExternalAttributesName($dirAttrName, \ZipArchive::OPSYS_UNIX, $dirAttrs);
}
}
} else {
$zip->addFile($f->getAbsolutePath(), $pathInZip);
Expand Down

0 comments on commit dad96cc

Please sign in to comment.