From 1b9472cc37a08979c2edc6d9a259134cffc31e6a Mon Sep 17 00:00:00 2001 From: Jerome Nadaud Date: Mon, 30 Sep 2013 19:01:11 +0200 Subject: [PATCH] [-] BO : FixBug #PSCFV-10291 - Remove temporary image on install --- classes/Tools.php | 15 +++++++++++++++ install-dev/models/install.php | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/classes/Tools.php b/classes/Tools.php index 38aee11b6..3634d61a4 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -704,6 +704,21 @@ class ToolsCore } return false; } + + /** + * Delete file + * + * @param string File path + * @param array Excluded files + */ + public static function deleteFile($file, $exclude_files = array()) + { + if (isset($exclude_files) && !is_array($exclude_files)) + $exclude_files = array($exclude_files); + + if (file_exists($file) && is_file($file) && array_search(basename($file), $exclude_files) === FALSE) + unlink($file); + } /** * Clear smarty cache folders diff --git a/install-dev/models/install.php b/install-dev/models/install.php index 94f64d287..249d7cddd 100644 --- a/install-dev/models/install.php +++ b/install-dev/models/install.php @@ -374,7 +374,7 @@ class InstallModelInstall extends InstallAbstractModel if (file_exists(_PS_TMP_IMG_DIR_)) foreach (scandir(_PS_TMP_IMG_DIR_) as $file) if ($file[0] != '.' && $file != 'index.php') - Tools::deleteDirectory(_PS_TMP_IMG_DIR_.DIRECTORY_SEPARATOR.$file); + Tools::deleteFile(_PS_TMP_IMG_DIR_.$file); $default_data = array( 'shop_name' => 'My Shop',