mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
#663: Fix for emptying a directory which contains broken symbolic links
SVN:trunk[2707]
This commit is contained in:
@@ -471,16 +471,30 @@ class SetupUtils
|
||||
throw new Exception("Attempting to delete directory: '$dir'");
|
||||
}
|
||||
|
||||
foreach(glob($dir . '/*') as $file)
|
||||
$aFiles = scandir($dir); // Warning glob('.*') does not seem to return the broken symbolic links, thus leaving a non-empty directory
|
||||
if ($aFiles !== false)
|
||||
{
|
||||
if(is_dir($file))
|
||||
foreach($aFiles as $file)
|
||||
{
|
||||
self::tidydir($file);
|
||||
rmdir($file);
|
||||
}
|
||||
else
|
||||
{
|
||||
unlink($file);
|
||||
if (($file != '.') && ($file != '..'))
|
||||
{
|
||||
if(is_dir($dir.'/'.$file))
|
||||
{
|
||||
self::tidydir($dir.'/'.$file);
|
||||
rmdir($dir.'/'.$file);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!unlink($dir.'/'.$file))
|
||||
{
|
||||
SetupPage::log("Warning - FAILED to remove file '$dir/$file'");
|
||||
}
|
||||
else if (file_exists($dir.'/'.$file))
|
||||
{
|
||||
SetupPage::log("Warning - FAILED to remove file '$dir/.$file'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user