From 4cd23bd2e483f39275c9fd8b86efa8292292a517 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 11 May 2009 14:43:34 +0000 Subject: [PATCH] "fixed filemanger bug: deleting a symlink to an directory, deletes not just the symlink but the whole directory" --- filemanager/inc/class.filemanager_ui.inc.php | 38 +++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/filemanager/inc/class.filemanager_ui.inc.php b/filemanager/inc/class.filemanager_ui.inc.php index 6004383d68..0a0dea8707 100644 --- a/filemanager/inc/class.filemanager_ui.inc.php +++ b/filemanager/inc/class.filemanager_ui.inc.php @@ -403,19 +403,39 @@ class filemanager_ui { case 'delete': $dirs = $files = $errs = 0; - foreach(egw_vfs::find($selected,array('depth'=>true)) as $path) + // we first delete all selected links (and files) + // feeding the links to dirs to egw_vfs::find() deletes the content of the dirs, not just the link! + foreach($selected as $key => $path) { - if (($is_dir = egw_vfs::is_dir($path) && !egw_vfs::is_link($path)) && egw_vfs::rmdir($path,0)) + if (!egw_vfs::is_dir($path) || egw_vfs::is_link($path)) { - ++$dirs; + if (egw_vfs::unlink($path)) + { + ++$files; + } + else + { + ++$errs; + } + unset($selected[$key]); } - elseif (!$is_dir && egw_vfs::unlink($path)) + } + if ($selected) // somethings left to delete + { + foreach(egw_vfs::find($selected,array('depth'=>true)) as $path) { - ++$files; - } - else - { - ++$errs; + if (($is_dir = egw_vfs::is_dir($path) && !egw_vfs::is_link($path)) && egw_vfs::rmdir($path,0)) + { + ++$dirs; + } + elseif (!$is_dir && egw_vfs::unlink($path)) + { + ++$files; + } + else + { + ++$errs; + } } } if ($errs)