Skip to content

Commit

Permalink
FIX the dolCopyDir fails if target dir does not exists.
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Feb 25, 2017
1 parent daf1dbb commit 08915d8
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions htdocs/core/lib/files.lib.php
Expand Up @@ -868,13 +868,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);

Expand All @@ -891,6 +901,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);
Expand Down

0 comments on commit 08915d8

Please sign in to comment.