Skip to content

Commit

Permalink
Try catch chmod.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jelle-S committed Mar 3, 2017
1 parent ea0254e commit 14be8f4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/PartialCleanDirs.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace DigipolisGent\Robo\Task\Deploy;

use Robo\Task\BaseTask;
use Symfony\Component\Filesystem\Exception\IOException;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;

Expand Down Expand Up @@ -245,7 +246,11 @@ protected function cleanDir($dir, $keep)
array_splice($items, -$keep);
}
foreach ($items as $item) {
$this->fs->chmod($item, 0777, 0000, true);
try {
$this->fs->chmod($item, 0777, 0000, true);
} catch (IOException $e) {
// If chmod didn't work, try to remove anyway.
}
$this->fs->remove($item);
}
}
Expand Down

0 comments on commit 14be8f4

Please sign in to comment.