Skip to content
This repository has been archived by the owner on Jan 6, 2020. It is now read-only.

Fixed Generator::mkdir when already exists #525

Merged
merged 1 commit into from
Nov 7, 2016

Conversation

HeahDude
Copy link
Contributor

@HeahDude HeahDude commented Nov 7, 2016

Closes #523.

@HeahDude HeahDude added the Bug label Nov 7, 2016
@javiereguiluz
Copy link
Contributor

👍

Status: reviewed.

@HeahDude thanks for fixing this ... and I'm sorry for having introduced it :(

@HeahDude HeahDude added the Ready label Nov 7, 2016
@@ -72,8 +72,9 @@ protected function renderFile($template, $target, $parameters)
*/
public static function mkdir($dir, $mode = 0777, $recursive = true)
{
mkdir($dir, $mode, $recursive);
self::writeln(sprintf(' <fg=green>created</> %s', self::relativizePath($dir)));
if (@mkdir($dir, $mode, $recursive)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What about checking for existence instead of silencing the operation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@xabbuh is 65e8333 ok for you?

Copy link
Member

Choose a reason for hiding this comment

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

👍 for @xabbuh proposal

@@ -72,7 +72,8 @@ protected function renderFile($template, $target, $parameters)
*/
public static function mkdir($dir, $mode = 0777, $recursive = true)
{
if (@mkdir($dir, $mode, $recursive)) {
if (!is_dir(dirname($dir))) {
mkdir($dir, $mode, $recursive);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please keep the silencing operator (Symfony always does @mkdir) because eventually an error will happen here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tests are failing anyway, let's revert this one.

@HeahDude HeahDude removed the Ready label Nov 7, 2016
@HeahDude HeahDude force-pushed the fix/mkdir branch 2 times, most recently from 2f24c9a to c43c993 Compare November 7, 2016 19:26
@HeahDude
Copy link
Contributor Author

HeahDude commented Nov 7, 2016

@fabpot tests are failing when I address @xabbuh's comment

@@ -72,8 +70,10 @@ protected function renderFile($template, $target, $parameters)
*/
public static function mkdir($dir, $mode = 0777, $recursive = true)
{
mkdir($dir, $mode, $recursive);
self::writeln(sprintf(' <fg=green>created</> %s', self::relativizePath($dir)));
if (!is_dir(dirname($dir))) {
Copy link
Member

Choose a reason for hiding this comment

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

should be $dir, not dirname($dir), no? same on the next line as well

if (!is_dir(dirname($target))) {
self::mkdir(dirname($target));
}
self::mkdir($target);
Copy link
Member

Choose a reason for hiding this comment

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

should be dirname($target)

@HeahDude
Copy link
Contributor Author

HeahDude commented Nov 7, 2016

Thanks @fabpot we're good to go now :)

@HeahDude HeahDude added Ready and removed Feature labels Nov 7, 2016
@fabpot
Copy link
Member

fabpot commented Nov 7, 2016

Thank you @HeahDude.

@fabpot fabpot merged commit 18b58df into sensiolabs:master Nov 7, 2016
fabpot added a commit that referenced this pull request Nov 7, 2016
This PR was merged into the 3.1.x-dev branch.

Discussion
----------

Fixed Generator::mkdir when already exists

Closes #523.

Commits
-------

18b58df Fixed Generator::mkdir when already exists
@HeahDude HeahDude deleted the fix/mkdir branch November 7, 2016 19:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants