Skip to content

Commit

Permalink
Merge pull request #2053 from shlinkio/develop
Browse files Browse the repository at this point in the history
Release 4.0.2
  • Loading branch information
acelaya authored Mar 9, 2024
2 parents a4e9c2f + 1fe2c93 commit f248001
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org).

## [4.0.2] - 2024-03-09
### Added
* *Nothing*

### Changed
* *Nothing*

### Deprecated
* *Nothing*

### Removed
* *Nothing*

### Fixed
* [#2021](https://github.com/shlinkio/shlink/issues/2021) Fix infinite GeoLite2 downloads.


## [4.0.1] - 2024-03-08
### Added
* *Nothing*
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"shlinkio/shlink-event-dispatcher": "^4.0",
"shlinkio/shlink-importer": "^5.3",
"shlinkio/shlink-installer": "^9.0",
"shlinkio/shlink-ip-geolocation": "^3.5",
"shlinkio/shlink-ip-geolocation": "^4.0",
"shlinkio/shlink-json": "^1.1",
"spiral/roadrunner": "^2023.3",
"spiral/roadrunner-cli": "^2.6",
Expand Down
4 changes: 2 additions & 2 deletions module/CLI/config/dependencies.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Shlinkio\Shlink\CLI;

use GeoIp2\Database\Reader;
use Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory;
use Laminas\ServiceManager\Factory\InvokableFactory;
use Shlinkio\Shlink\Common\Doctrine\NoDbNameConnectionFactory;
Expand All @@ -18,6 +17,7 @@
use Shlinkio\Shlink\Core\Visit;
use Shlinkio\Shlink\Installer\Factory\ProcessHelperFactory;
use Shlinkio\Shlink\IpGeolocation\GeoLite2\DbUpdater;
use Shlinkio\Shlink\IpGeolocation\GeoLite2\GeoLite2ReaderFactory;
use Shlinkio\Shlink\Rest\Service\ApiKeyService;
use Symfony\Component\Console as SymfonyCli;
use Symfony\Component\Lock\LockFactory;
Expand Down Expand Up @@ -76,7 +76,7 @@
ConfigAbstractFactory::class => [
GeoLite\GeolocationDbUpdater::class => [
DbUpdater::class,
Reader::class,
GeoLite2ReaderFactory::class,
LOCAL_LOCK_FACTORY,
TrackingOptions::class,
],
Expand Down
12 changes: 10 additions & 2 deletions module/CLI/src/GeoLite/GeolocationDbUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Shlinkio\Shlink\CLI\GeoLite;

use Cake\Chronos\Chronos;
use Closure;
use GeoIp2\Database\Reader;
use MaxMind\Db\Reader\Metadata;
use Shlinkio\Shlink\CLI\Exception\GeolocationDbUpdateFailedException;
Expand All @@ -21,12 +22,19 @@ class GeolocationDbUpdater implements GeolocationDbUpdaterInterface
{
private const LOCK_NAME = 'geolocation-db-update';

/** @var Closure(): Reader */
private readonly Closure $geoLiteDbReaderFactory;

/**
* @param callable(): Reader $geoLiteDbReaderFactory
*/
public function __construct(
private readonly DbUpdaterInterface $dbUpdater,
private readonly Reader $geoLiteDbReader,
callable $geoLiteDbReaderFactory,
private readonly LockFactory $locker,
private readonly TrackingOptions $trackingOptions,
) {
$this->geoLiteDbReaderFactory = $geoLiteDbReaderFactory(...);
}

/**
Expand Down Expand Up @@ -57,7 +65,7 @@ private function downloadIfNeeded(?callable $beforeDownload, ?callable $handlePr
return $this->downloadNewDb(false, $beforeDownload, $handleProgress);
}

$meta = $this->geoLiteDbReader->metadata();
$meta = ($this->geoLiteDbReaderFactory)()->metadata();
if ($this->buildIsTooOld($meta)) {
return $this->downloadNewDb(true, $beforeDownload, $handleProgress);
}
Expand Down
2 changes: 1 addition & 1 deletion module/CLI/test/GeoLite/GeolocationDbUpdaterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ private function geolocationDbUpdater(?TrackingOptions $options = null): Geoloca

return new GeolocationDbUpdater(
$this->dbUpdater,
$this->geoLiteDbReader,
fn () => $this->geoLiteDbReader,
$locker,
$options ?? new TrackingOptions(),
);
Expand Down

0 comments on commit f248001

Please sign in to comment.