diff options
author | Stefan Giehl <stefan@matomo.org> | 2022-02-16 02:45:52 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-16 02:45:52 +0300 |
commit | bf92c8baa9534556d3062c86fad48ae75c81d65d (patch) | |
tree | 1551bc6f6ce998148ed5a18165cb18bc835eb80b /plugins/GeoIp2 | |
parent | 0753cb03397f52eeb74d03ade2cd9e68893fe684 (diff) |
Check folder & permission before downloading a GeoIP database (#18799)
Diffstat (limited to 'plugins/GeoIp2')
-rw-r--r-- | plugins/GeoIp2/GeoIP2AutoUpdater.php | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/plugins/GeoIp2/GeoIP2AutoUpdater.php b/plugins/GeoIp2/GeoIP2AutoUpdater.php index 29bcafd975..2028e9cb83 100644 --- a/plugins/GeoIp2/GeoIP2AutoUpdater.php +++ b/plugins/GeoIp2/GeoIP2AutoUpdater.php @@ -14,6 +14,7 @@ use Piwik\Common; use Piwik\Config; use Piwik\Container\StaticContainer; use Piwik\Date; +use Piwik\Filesystem; use Piwik\Http; use Piwik\Log; use Piwik\Option; @@ -195,7 +196,14 @@ class GeoIP2AutoUpdater extends Task public static function getTemporaryFolder($file, $isDownload = false) { - return \Piwik\Container\StaticContainer::get('path.tmp') . '/latest/' . $file . ($isDownload ? '.download' : ''); + $folder = \Piwik\Container\StaticContainer::get('path.tmp') . '/latest/'; + if (!is_dir($folder)) { + Filesystem::mkdir($folder); + } + if (!is_writable($folder)) { + throw new \Exception("GeoIP2AutoUpdater: Can't create temporary file for download."); + } + return $folder . $file . ($isDownload ? '.download' : ''); } /** |