From ce20d55e7759daa04e774481e0fdf3a1f44101c4 Mon Sep 17 00:00:00 2001 From: Shagshag Date: Mon, 12 Aug 2013 04:28:58 +0200 Subject: [PATCH] ProductDownload::getNewFilename() little optimisation Avoid recursion --- classes/ProductDownload.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/classes/ProductDownload.php b/classes/ProductDownload.php index 9936e635a..a52441f62 100644 --- a/classes/ProductDownload.php +++ b/classes/ProductDownload.php @@ -299,10 +299,10 @@ class ProductDownloadCore extends ObjectModel */ public static function getNewFilename() { - $ret = sha1(microtime()); - if (file_exists(_PS_DOWNLOAD_DIR_.$ret)) - $ret = ProductDownload::getNewFilename(); - return $ret; + do { + $filename = sha1(microtime()); + } while (file_exists(_PS_DOWNLOAD_DIR_.$filename)); + return $filename; } /** @@ -314,4 +314,4 @@ class ProductDownloadCore extends ObjectModel { return Configuration::get('PS_VIRTUAL_PROD_FEATURE_ACTIVE'); } -} \ No newline at end of file +}