mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 11:08:45 +02:00
✅ Fix failing directory removal
This commit is contained in:
@@ -741,22 +741,20 @@ class SetupUtils
|
|||||||
throw new Exception("Attempting to delete directory: '$dir'");
|
throw new Exception("Attempting to delete directory: '$dir'");
|
||||||
}
|
}
|
||||||
|
|
||||||
$aFiles = scandir($dir); // Warning glob('.*') does not seem to return the broken symbolic links, thus leaving a non-empty directory
|
if (is_dir($dir)) {
|
||||||
if ($aFiles !== false) {
|
$aFiles = scandir($dir); // Warning glob('.*') does not seem to return the broken symbolic links, thus leaving a non-empty directory
|
||||||
foreach ($aFiles as $file) {
|
if ($aFiles !== false) {
|
||||||
if (($file != '.') && ($file != '..')) {
|
foreach ($aFiles as $file) {
|
||||||
if (is_dir($dir.'/'.$file)) {
|
if (($file != '.') && ($file != '..')) {
|
||||||
self::tidydir($dir.'/'.$file);
|
if (is_dir($dir.'/'.$file)) {
|
||||||
self::rmdir_safe($dir.'/'.$file);
|
self::tidydir($dir.'/'.$file);
|
||||||
}
|
self::rmdir_safe($dir.'/'.$file);
|
||||||
else {
|
} else {
|
||||||
if (!unlink($dir.'/'.$file))
|
if (!unlink($dir.'/'.$file)) {
|
||||||
{
|
SetupLog::Ok("Warning - FAILED to remove file '$dir/$file'");
|
||||||
SetupLog::Ok("Warning - FAILED to remove file '$dir/$file'");
|
} else if (file_exists($dir.'/'.$file)) {
|
||||||
}
|
SetupLog::Ok("Warning - FAILED to remove file '$dir/.$file'");
|
||||||
else if (file_exists($dir.'/'.$file))
|
}
|
||||||
{
|
|
||||||
SetupLog::Ok("Warning - FAILED to remove file '$dir/.$file'");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -790,17 +788,19 @@ class SetupUtils
|
|||||||
// avoid unnecessary warning
|
// avoid unnecessary warning
|
||||||
// Try 100 times...
|
// Try 100 times...
|
||||||
$i = 100;
|
$i = 100;
|
||||||
while ((@rmdir($dir) === false) && $i > 0) {
|
if (is_dir($dir)) {
|
||||||
// Magic trick for windows
|
while ((@rmdir($dir) === false) && $i > 0) {
|
||||||
// sometimes the folder is empty but rmdir fails
|
// Magic trick for windows
|
||||||
$oDir = opendir($dir);
|
// sometimes the folder is empty but rmdir fails
|
||||||
if ($oDir !== false) {
|
$oDir = opendir($dir);
|
||||||
closedir($oDir);
|
if ($oDir !== false) {
|
||||||
|
closedir($oDir);
|
||||||
|
}
|
||||||
|
$i--;
|
||||||
|
}
|
||||||
|
if ($i == 0) {
|
||||||
|
rmdir($dir);
|
||||||
}
|
}
|
||||||
$i--;
|
|
||||||
}
|
|
||||||
if ($i == 0) {
|
|
||||||
rmdir($dir);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user