From fdcbb86f431b754ae22bad8c98a68760174c974e Mon Sep 17 00:00:00 2001 From: eldadfux Date: Wed, 13 Nov 2019 00:32:59 +0200 Subject: [PATCH] Handle mkdir errors with exceptions --- src/Resize/Resize.php | 4 +++- src/Storage/Device.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Resize/Resize.php b/src/Resize/Resize.php index a56d3688df..30bc109f42 100644 --- a/src/Resize/Resize.php +++ b/src/Resize/Resize.php @@ -113,7 +113,9 @@ class Resize { // Create directory with write permissions if (null !== $path && !file_exists(dirname($path))) { - mkdir(dirname($path), 0777, true); + if (!@mkdir(dirname($path), 0755, true)) { + throw new Exception('Can\'t create directory '.dirname($path)); + } } switch ($type) { diff --git a/src/Storage/Device.php b/src/Storage/Device.php index 8fab1b41f6..d111f4ca84 100644 --- a/src/Storage/Device.php +++ b/src/Storage/Device.php @@ -71,7 +71,7 @@ abstract class Device } if (!file_exists(dirname($path))) { // Checks if directory path to file exists - if (!mkdir(dirname($path), 0755, true)) { + if (!@mkdir(dirname($path), 0755, true)) { throw new Exception('Can\'t create directory '.dirname($path)); } }