diff --git a/Controller/Adminhtml/System/Config/Geoip.php b/Controller/Adminhtml/System/Config/Geoip.php
index 1b0fd9f..5e39221 100755
--- a/Controller/Adminhtml/System/Config/Geoip.php
+++ b/Controller/Adminhtml/System/Config/Geoip.php
@@ -1,118 +1,128 @@
-resultJsonFactory = $resultJsonFactory;
- $this->_directoryList = $directoryList;
- $this->_helperData = $helperData;
-
- parent::__construct($context);
- }
-
- /**
- * @return $this
- */
- public function execute()
- {
- $status = false;
- try {
- $path = $this->_directoryList->getPath('var') . '/Mageplaza/GeoIp/GeoIp';
- if (!file_exists($path)) {
- mkdir($path, 0777, true);
- }
- $folder = scandir($path, true);
- $pathFile = $path . '/' . $folder[0] . '/GeoLite2-City.mmdb';
- if (file_exists($pathFile)) {
- foreach (scandir($path . '/' . $folder[0], true) as $filename) {
- if ($filename == '..' || $filename == '.') {
- continue;
- }
- unlink($path . '/' . $folder[0] . '/' . $filename);
- }
- rmdir($path . '/' . $folder[0]);
- }
-
- file_put_contents($path . '/GeoLite2-City.tar.gz', fopen($this->_helperData->getDownloadPath(), 'r'));
- if (!in_array('phar', stream_get_wrappers(), true)) {
- stream_wrapper_restore('phar');
- }
-
- $phar = new PharData($path . '/GeoLite2-City.tar.gz');
- $phar->extractTo($path);
- $status = true;
- $message = __('Download library success!');
- } catch (Exception $e) {
- $message = __('Can\'t download file. Please try again! %1', $e->getMessage());
- }
-
- /** @var Json $result */
- $result = $this->resultJsonFactory->create();
-
- return $result->setData(['success' => $status, 'message' => $message]);
- }
-}
+resultJsonFactory = $resultJsonFactory;
+ $this->_directoryList = $directoryList;
+ $this->_helperData = $helperData;
+ $this->_logger = $logger;
+
+ parent::__construct($context);
+ }
+
+ /**
+ * @return $this
+ */
+ public function execute()
+ {
+ $status = false;
+ try {
+ $path = $this->_directoryList->getPath('var') . '/Mageplaza/GeoIp/GeoIp';
+ if (!file_exists($path)) {
+ mkdir($path, 0777, true);
+ }
+ $folder = scandir($path, true);
+ $pathFile = $path . '/' . $folder[0] . '/GeoLite2-City.mmdb';
+ if (file_exists($pathFile)) {
+ foreach (scandir($path . '/' . $folder[0], true) as $filename) {
+ if ($filename == '..' || $filename == '.') {
+ continue;
+ }
+ unlink($path . '/' . $folder[0] . '/' . $filename);
+ }
+ rmdir($path . '/' . $folder[0]);
+ }
+
+ file_put_contents($path . '/GeoLite2-City.tar.gz', fopen($this->_helperData->getDownloadPath(), 'r'));
+ if (!in_array('phar', stream_get_wrappers(), true)) {
+ stream_wrapper_restore('phar');
+ }
+
+ $phar = new PharData($path . '/GeoLite2-City.tar.gz');
+ $phar->extractTo($path);
+ $status = true;
+ $message = __('Download library success!');
+ } catch (Exception $e) {
+ $this->_logger->info($e->getMessage());
+ $message = __('Can\'t download file. Please try again!
You can find out more in the error log.' );
+ }
+
+ /** @var Json $result */
+ $result = $this->resultJsonFactory->create();
+
+ return $result->setData(['success' => $status, 'message' => $message]);
+ }
+}
diff --git a/composer.json b/composer.json
index f78d3c7..517ee78 100644
--- a/composer.json
+++ b/composer.json
@@ -6,7 +6,7 @@
"geoip2/geoip2": "~2.0"
},
"type": "magento2-module",
- "version": "4.0.0",
+ "version": "4.0.1",
"license": "proprietary",
"authors": [
{