From b5057f44b13f8096002720048156f76c5cb19879 Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Fri, 22 Dec 2017 10:16:23 +0100 Subject: [PATCH] Avoid race condition --- src/PhpSpreadsheet/Helper/Sample.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/PhpSpreadsheet/Helper/Sample.php b/src/PhpSpreadsheet/Helper/Sample.php index 83c8cd9b..d021c922 100644 --- a/src/PhpSpreadsheet/Helper/Sample.php +++ b/src/PhpSpreadsheet/Helper/Sample.php @@ -141,7 +141,9 @@ class Sample { $tempFolder = sys_get_temp_dir() . '/phpspreadsheet'; if (!is_dir($tempFolder)) { - mkdir($tempFolder); + if (! mkdir($tempFolder) && ! is_dir($tempFolder)) { + throw new \RuntimeException(sprintf('Directory "%s" was not created', $tempFolder)); + } } return $tempFolder;