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

taskPack modified to correctly set file permissions in ZIP files (ins… #888

Closed
wants to merge 1 commit into from

Conversation

alex-scott
Copy link

…tead of default 0666)

Overview

This pull request:

  • Adds a feature

Summary

taskPack modified to correctly set file permissions in ZIP files

Description

Without these changes, on any Unix/Linux system, created ZIP files extracts with all files having permissions 0666 and there is no way to change it. This fix adds code to automatically set permissions in archive same to permissions of original files.

@@ -245,11 +245,21 @@ protected function addItemsToZip($zip, $items)
if (!$zip->addFile($file->getRealpath(), "{$placementLocation}/{$relativePathname}")) {
return Result::error($this, "Could not add directory $filesystemLocation to the archive; error adding {$file->getRealpath()}.");
}
if (stripos(PHP_OS, 'WIN') !== 0)

Choose a reason for hiding this comment

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

Expected 1 space after closing parenthesis; found 21

@@ -245,11 +245,21 @@ protected function addItemsToZip($zip, $items)
if (!$zip->addFile($file->getRealpath(), "{$placementLocation}/{$relativePathname}")) {
return Result::error($this, "Could not add directory $filesystemLocation to the archive; error adding {$file->getRealpath()}.");
}
if (stripos(PHP_OS, 'WIN') !== 0)
{
$zip->setExternalAttributesName("{$placementLocation}/{$relativePathname}", \ZipArchive::OPSYS_UNIX,

Choose a reason for hiding this comment

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

  • Opening parenthesis of a multi-line function call must be the last content on the line
  • Only one argument is allowed per line in a multi-line function call

if (stripos(PHP_OS, 'WIN') !== 0)
{
$zip->setExternalAttributesName("{$placementLocation}/{$relativePathname}", \ZipArchive::OPSYS_UNIX,
$file->getPerms() << 16);

Choose a reason for hiding this comment

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

  • Multi-line function call not indented correctly; expected 24 spaces but found 28
  • Closing parenthesis of a multi-line function call must be on a line by itself

}
} elseif (is_file($filesystemLocation)) {
if (!$zip->addFile($filesystemLocation, $placementLocation)) {
return Result::error($this, "Could not add file $filesystemLocation to the archive.");
}
if (stripos(PHP_OS, 'WIN') !== 0)

Choose a reason for hiding this comment

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

Expected 1 space after closing parenthesis; found 17

}
} elseif (is_file($filesystemLocation)) {
if (!$zip->addFile($filesystemLocation, $placementLocation)) {
return Result::error($this, "Could not add file $filesystemLocation to the archive.");
}
if (stripos(PHP_OS, 'WIN') !== 0)
{
$zip->setExternalAttributesName($placementLocation, \ZipArchive::OPSYS_UNIX,

Choose a reason for hiding this comment

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

  • Opening parenthesis of a multi-line function call must be the last content on the line
  • Only one argument is allowed per line in a multi-line function call

if (stripos(PHP_OS, 'WIN') !== 0)
{
$zip->setExternalAttributesName($placementLocation, \ZipArchive::OPSYS_UNIX,
fileperms($filesystemLocation) << 16);

Choose a reason for hiding this comment

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

  • Multi-line function call not indented correctly; expected 20 spaces but found 24
  • Closing parenthesis of a multi-line function call must be on a line by itself

@MirazMac
Copy link

MirazMac commented Oct 4, 2019

It seems it also sets the permission 0666 for files on Windows systems as well, I'm using Windows 10 and when I use robo to create an archive and upload it to a linux web server it shows the files have a permission of 0666. Is there any fix for windows systems to retain the permissions?

@alex-scott
Copy link
Author

I may be wrong, but on Windows you will have to specify permissions explictly as there is nothing to inspect.
Sorry, I have no time to fix all these warnings, decided to solve problem locally.

@greg-1-anderson
Copy link
Member

Continuation here appreciated, if anyone has time to take over here.

@MirazMac
Copy link

MirazMac commented Oct 5, 2019

Continuation here appreciated, if anyone has time to take over here.

I submitted a pull request with fixes #897

@greg-1-anderson
Copy link
Member

Continued in #897

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.

4 participants