This commit is contained in:
Batandwa 2016-09-30 19:29:57 +00:00 committed by GitHub
commit c13ae306bb

View file

@ -269,14 +269,21 @@ class Build extends BuildBase
*/ */
public function removeBuildDirectory() public function removeBuildDirectory()
{ {
$buildPath = $this->getBuildPath(); // Get the path and remove the trailing slash as this may prompt PHP
// to see this as a directory even if it's a link.
$buildPath = rtrim($this->getBuildPath(), '/');
if (!$buildPath || !is_dir($buildPath)) { if (!$buildPath || !is_dir($buildPath)) {
return; return;
} }
if (is_link($buildPath)) {
// Remove the symlink without using recursive.
exec(sprintf(IS_WIN ? 'rmdir /S /Q "%s"' : 'rm "%s"', $buildPath));
} else {
exec(sprintf(IS_WIN ? 'rmdir /S /Q "%s"' : 'rm -Rf "%s"', $buildPath)); exec(sprintf(IS_WIN ? 'rmdir /S /Q "%s"' : 'rm -Rf "%s"', $buildPath));
} }
}
/** /**
* Get the number of seconds a build has been running for. * Get the number of seconds a build has been running for.