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
MINIFICPP-1410 Add permissions property support for Putfile processor #942
Conversation
With the new default directory creating permissions, the change of test directory permissions is not needed anymore.
There is an incompatilibity issue with libboost and gcc 4.8 which causes throw of std::bad_allow or segmentation fault in tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, LGTM!
|
||
#ifndef WIN32 | ||
class FilePermissions { | ||
static const uint32_t MINIMUM_INVALID_PERMISSIONS_VALUE = 1 << 9; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice solution :)
PROCESSORS.md
Outdated
@@ -899,6 +899,8 @@ In the list below, the names of required properties appear in bold. Any other pr | |||
|**Create Missing Directories**|true||If true, then missing destination directories will be created. If false, flowfiles are penalized and sent to failure.| | |||
|Directory|.||The output directory to which to put files<br/>**Supports Expression Language: true**| | |||
|Maximum File Count|-1||Specifies the maximum number of files that can exist in the output directory| | |||
|Permissions|||Sets the permissions on the output file to the value of this attribute. Format must be in octal number (e.g. 644 or 0755). Not supported on Windows systems.| | |||
|Directory Permissions|||Sets the permissions on the directories being created if 'Create Missing Directories' property is set. Format must be format octal number (e.g. 644 or 0755). Not supported on Windows systems.| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: two "format"s. I would get rid of all "format"s and write "Must be an octal number (e.g. 644 or 0755)." in both property descriptions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 163bbea
core::Property PutFile::Permissions( | ||
core::PropertyBuilder::createProperty("Permissions") | ||
->withDescription("Sets the permissions on the output file to the value of this attribute. " | ||
"Format must be format octal number (e.g. 644 or 0755). Not supported on Windows systems.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
even more "format"s here :)
same suggestion as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 163bbea
core::PropertyBuilder::createProperty("Directory Permissions") | ||
->withDescription("Sets the permissions on the directories being created if 'Create Missing Directories' property is set. " | ||
"Format must be format octal number (e.g. 644 or 0755). Not supported on Windows systems.") | ||
->build()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if these are not set? I would have expected a default value here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case it works the same way as boost::filesystem::create_directory
which is creating the directory in mode 777
then applies the system's default umask.
return S_ISDIR(dir_stat.st_mode); | ||
} | ||
|
||
inline int exists(const std::string& path) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see that returning 0 (true) and -1 (false) fits into the existing pattern, but I think it would be better to return a bool
at least from is_directory()
and exists()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 163bbea
There are multiple changes done in this PR:
EXCLUDE_BOOST
is not defined and libboost is present on the system, it will be used marked with theUSE_BOOST
definition.Permissions
andDirectory Permissions
properties added toPutfile
processor for non-Windows systems for changing the permissions of the newly created output directories and the output file.777 & umask
instead of the previous700
to be in sync with the boost implementation ofboost::filesystem::create_directory
.Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.
In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
For all changes:
Is there a JIRA ticket associated with this PR? Is it referenced
in the commit message?
Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
Has your PR been rebased against the latest commit within the target branch (typically main)?
Is your initial contribution a single, squashed commit?
For code changes:
For documentation related changes:
Note:
Please ensure that once the PR is submitted, you check GitHub Actions CI results for build issues and submit an update to your PR as soon as possible.