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

[downstream] Report failures for SignApp and SignCore #2724

Merged
merged 3 commits into from
Dec 21, 2016
Merged

Conversation

LukasReschke
Copy link
Member

@LukasReschke LukasReschke added 3. to review Waiting for reviews downstream labels Dec 16, 2016
@LukasReschke LukasReschke added this to the Nextcloud 12.0 milestone Dec 16, 2016
@mention-bot
Copy link

@LukasReschke, thanks for your PR! By analyzing the history of the files in this pull request, we identified @rullzer and @nickvergessen to be potential reviewers.

throw new \Exception('Directory does not exist.');
}
$appInfoDir = $path . '/appinfo';
$this->fileAccessHelper->assertDirectoryExists($path);
Copy link
Member

Choose a reason for hiding this comment

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

is_dir does not fail, when one of the parents doesn't exist, so this can be removed in favor of the next line

*/
public function writeCoreSignature(X509 $certificate,
RSA $rsa,
$path) {
$coreDir = $path . '/core';
$this->fileAccessHelper->assertDirectoryExists($path);
Copy link
Member

Choose a reason for hiding this comment

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

is_dir does not fail, when one of the parents doesn't exist, so this can be removed in favor of the next line

);
);
} catch (\Exception $e){
if (!$this->fileAccessHelper->is_writeable($appInfoDir)){
Copy link
Member

Choose a reason for hiding this comment

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

check if signature.json is writeable instead of the folder?

Copy link
Member Author

Choose a reason for hiding this comment

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

is_writable will return false is the file doesn't exist yet. So I think checking for the folder is right here.

);
);
} catch (\Exception $e){
if (!$this->fileAccessHelper->is_writeable($coreDir)){
Copy link
Member

Choose a reason for hiding this comment

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

Same here, check that signature.json is writable

* @return bool
*/
public function is_writeable($path){
return is_writeable($path);
Copy link
Member

Choose a reason for hiding this comment

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

bildschirmfoto vom 2016-12-19 11-44-19

Copy link
Member Author

Choose a reason for hiding this comment

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

I suspect this has been done to allow mocking here. Let me actually write tests for this and then that makes some more sense.

Copy link
Member

Choose a reason for hiding this comment

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

Well no problem with the wrapper name, but the actual function in php is:

function is_writeable($path) {
    return is_writable($path);
}

so killing the e will reduce nesting by 1

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah. Gotcha :)

Signed-off-by: Lukas Reschke <[email protected]>
@LukasReschke
Copy link
Member Author

@nickvergessen Adjusted as requested and now all paths should also be covered by tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants