Skip to content
Snippets Groups Projects
Commit 3fa19f84 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

FIX the dolCopyDir fails if target dir does not exists.

parent 4723eac2
No related branches found
No related tags found
No related merge requests found
......@@ -515,13 +515,23 @@ function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists)
$result=0;
dol_syslog("files.lib.php::dolCopyr srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." overwriteifexists=".$overwriteifexists);
dol_syslog("files.lib.php::dolCopyDir srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." overwriteifexists=".$overwriteifexists);
if (empty($srcfile) || empty($destfile)) return -1;
$destexists=dol_is_dir($destfile);
if (! $overwriteifexists && $destexists) return 0;
if (! $destexists)
{
// We must set mask just before creating dir, becaause it can be set differently by dol_copy
umask(0);
$dirmaskdec=octdec($newmask);
if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $dirmaskdec=octdec($conf->global->MAIN_UMASK);
$dirmaskdec |= octdec('0200'); // Set w bit required to be able to create content for recursive subdirs files
dol_mkdir($destfile."/".$file, '', decoct($dirmaskdec));
}
$srcfile=dol_osencode($srcfile);
$destfile=dol_osencode($destfile);
......@@ -538,6 +548,7 @@ function dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists)
{
if (!is_dir($destfile."/".$file))
{
// We must set mask just before creating dir, becaause it can be set differently by dol_copy
umask(0);
$dirmaskdec=octdec($newmask);
if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $dirmaskdec=octdec($conf->global->MAIN_UMASK);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment