mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-06 23:33:13 +08:00
Ensured events triggered as a result of a new visit are never skipped
This commit is contained in:
@@ -52,6 +52,12 @@ class LocateVisit
|
||||
return;
|
||||
}
|
||||
|
||||
$this->locateVisit($visitId, $shortUrlVisited->originalIpAddress(), $visit);
|
||||
$this->eventDispatcher->dispatch(new VisitLocated($visitId));
|
||||
}
|
||||
|
||||
private function locateVisit(string $visitId, ?string $originalIpAddress, Visit $visit): void
|
||||
{
|
||||
if (! $this->dbUpdater->databaseFileExists()) {
|
||||
$this->logger->warning('Tried to locate visit with id "{visitId}", but a GeoLite2 db was not found.', [
|
||||
'visitId' => $visitId,
|
||||
@@ -59,12 +65,6 @@ class LocateVisit
|
||||
return;
|
||||
}
|
||||
|
||||
$this->locateVisit($visitId, $shortUrlVisited->originalIpAddress(), $visit);
|
||||
$this->eventDispatcher->dispatch(new VisitLocated($visitId));
|
||||
}
|
||||
|
||||
private function locateVisit(string $visitId, ?string $originalIpAddress, Visit $visit): void
|
||||
{
|
||||
$isLocatable = $originalIpAddress !== null || $visit->isLocatable();
|
||||
$addr = $originalIpAddress ?? $visit->getRemoteAddr();
|
||||
|
||||
|
||||
@@ -26,11 +26,13 @@ class UpdateGeoLiteDb
|
||||
$beforeDownload = fn (bool $olderDbExists) => $this->logger->notice(
|
||||
sprintf('%s GeoLite2 db file...', $olderDbExists ? 'Updating' : 'Downloading'),
|
||||
);
|
||||
$handleProgress = function (int $total, int $downloaded, bool $olderDbExists): void {
|
||||
if ($total > $downloaded) {
|
||||
$messageLogged = false;
|
||||
$handleProgress = function (int $total, int $downloaded, bool $olderDbExists) use (&$messageLogged): void {
|
||||
if ($messageLogged || $total > $downloaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
$messageLogged = true;
|
||||
$this->logger->notice(sprintf('Finished %s GeoLite2 db file', $olderDbExists ? 'updating' : 'downloading'));
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user