fix 'mkdir(): File exists' error on create directory from parallel

processes
This commit is contained in:
Andrew Shpota
2017-07-14 15:09:38 +03:00
parent a6f3a518e1
commit 6768340a97

View File

@@ -37,9 +37,11 @@ class Smarty_Internal_Runtime_WriteFile
} }
$_dirpath = dirname($_filepath); $_dirpath = dirname($_filepath);
// if subdirs, create dir structure
if ($_dirpath !== '.' && !file_exists($_dirpath)) { // if subdirs, create dir structure
mkdir($_dirpath, $_dir_perms, true); if ($_dirpath !== '.' && !@mkdir($_dirpath, $_dir_perms, true) && !is_dir($_dirpath)) {
error_reporting($_error_reporting);
throw new SmartyException("unable to create directory {$_dirpath}");
} }
// write to tmp file, then move to overt file lock race condition // write to tmp file, then move to overt file lock race condition