From b9511fd4c692fbcae509f949c9dac40e6c52fba7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Aug 2017 00:40:32 +0200 Subject: [PATCH] FIX Do not delete files into sym links --- htdocs/core/lib/files.lib.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index c433dc4a5fb..cc918504a9a 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -287,7 +287,7 @@ function dol_dir_list_in_database($path, $filter="", $excludefilter=null, $sortc /** * Complete $filearray with data from database. * This will call doldir_list_indatabase to complate filearray. - * + * * @param $filearray Array of files get using dol_dir_list * @param $relativedir Relative dir from DOL_DATA_ROOT * @return void @@ -295,7 +295,7 @@ function dol_dir_list_in_database($path, $filter="", $excludefilter=null, $sortc function completeFileArrayWithDatabaseInfo(&$filearray, $relativedir) { global $db, $user; - + $filearrayindatabase = dol_dir_list_in_database($relativedir, '', null, 'name', SORT_ASC); //var_dump($filearray); @@ -672,7 +672,7 @@ function dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1) } /** - * Copy a dir to another dir. + * Copy a dir to another dir. This include recursive subdirectories. * * @param string $srcfile Source file (a directory) * @param string $destfile Destination file (a directory) @@ -716,7 +716,7 @@ function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayrep { if ($file!="." && $file!="..") { - if (is_dir($ossrcfile."/".$file)) + if (is_dir($ossrcfile."/".$file) && ! is_link($ossrcfile."/".$file)) { //var_dump("xxx dolCopyDir $srcfile/$file, $destfile/$file, $newmask, $overwriteifexists"); $tmpresult=dolCopyDir($srcfile."/".$file, $destfile."/".$file, $newmask, $overwriteifexists, $arrayreplacement); @@ -1084,7 +1084,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable /** * Remove a file or several files with a mask. - * This delete file physically but also database indexes. + * This delete file physically but also database indexes. * * @param string $file File to delete or mask of files to delete * @param int $disableglob Disable usage of glob like * so function is an exact delete function that will return error if no file found @@ -1239,7 +1239,7 @@ function dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$ if ($item != "." && $item != "..") { - if (is_dir(dol_osencode("$dir/$item"))) + if (is_dir(dol_osencode("$dir/$item")) && ! is_link(dol_osencode("$dir/$item"))) { $count=dol_delete_dir_recursive("$dir/$item", $count, $nophperrors, 0, $countdeleted); } @@ -1334,7 +1334,7 @@ function dol_meta_create($object) { global $conf; - // Create meta file + // Create meta file if (empty($conf->global->MAIN_DOC_CREATE_METAFILE)) return 0; // By default, no metafile. // Define parent dir of elements @@ -1391,7 +1391,7 @@ function dol_meta_create($object) return 1; } - else + else { dol_syslog('FailedToDetectDirInDolMetaCreateFor'.$object->element, LOG_WARNING); }