Commit 6f81ca73 authored by omega8cc's avatar omega8cc

Use strict checks: is_file() and/or is_link() instead of file_exists() before attempting unlink()

parent 56364d1c
......@@ -118,7 +118,7 @@ class Provision_FileSystem extends Provision_ChainedState {
function unlink($path) {
$this->_clear_state();
if (file_exists($path) || is_link($path)) {
if (is_file($path) || is_link($path)) {
$this->last_status = unlink($path);
}
else {
......
......@@ -974,7 +974,7 @@ function _provision_client_create_symlink() {
function _provision_client_delete_old_symlink() {
$previous = d()->server->clients_path . '/' . d()->client_name . '/' . d()->uri;
// this is necessary because unlink doesn't fail on missing files (!)
$found = (file_exists($previous) || is_link($previous));
$found = (is_file($previous) || is_link($previous));
provision_file()->unlink($previous);
if (!$found) {
drush_log(dt("couldn't find previous client symlink, iterating through all sites"));
......@@ -983,7 +983,7 @@ function _provision_client_delete_old_symlink() {
while (($file = readdir($dh)) !== false) {
if ($file != '.' && $file != '..') {
$path = d()->server->clients_path . '/' . $file . '/' . d()->uri;
if (file_exists($path) || is_link($path)) {
if (is_file($path) || is_link($path)) {
provision_file()->unlink($path);
drush_log(dt("removed previous symlink in @path", array("@path" => $path)), 'success');
break; // found it
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment