Fixed merge conflicts

This commit is contained in:
Alejandro Celaya
2021-05-30 13:31:37 +02:00
6 changed files with 60 additions and 4 deletions

View File

@@ -8,6 +8,7 @@ use Cake\Chronos\Chronos;
use GeoIp2\Database\Reader;
use MaxMind\Db\Reader\Metadata;
use Shlinkio\Shlink\CLI\Exception\GeolocationDbUpdateFailedException;
use Shlinkio\Shlink\Core\Options\TrackingOptions;
use Shlinkio\Shlink\IpGeolocation\Exception\RuntimeException;
use Shlinkio\Shlink\IpGeolocation\GeoLite2\DbUpdaterInterface;
use Symfony\Component\Lock\LockFactory;
@@ -21,7 +22,8 @@ class GeolocationDbUpdater implements GeolocationDbUpdaterInterface
public function __construct(
private DbUpdaterInterface $dbUpdater,
private Reader $geoLiteDbReader,
private LockFactory $locker
private LockFactory $locker,
private TrackingOptions $trackingOptions
) {
}
@@ -30,6 +32,10 @@ class GeolocationDbUpdater implements GeolocationDbUpdaterInterface
*/
public function checkDbUpdate(?callable $beforeDownload = null, ?callable $handleProgress = null): void
{
if ($this->trackingOptions->disableTracking() || $this->trackingOptions->disableIpTracking()) {
return;
}
$lock = $this->locker->createLock(self::LOCK_NAME);
$lock->acquire(true); // Block until lock is released