MirrorCache/0001-Avoid-by-and-ru-mrrors-for-ua-requests.patch

48 lines
1.4 KiB
Diff

From 7d9346897af13e5e5ca1752b7a9cfb5718305228 Mon Sep 17 00:00:00 2001
From: Andrii Nikitin <anikitin@suse.de>
Date: Thu, 1 Sep 2022 14:11:40 +0200
Subject: [PATCH] Avoid by and ru mrrors for ua requests
---
lib/MirrorCache/Datamodule.pm | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/lib/MirrorCache/Datamodule.pm b/lib/MirrorCache/Datamodule.pm
index 5e5c2d8..7fb4cfd 100644
--- a/lib/MirrorCache/Datamodule.pm
+++ b/lib/MirrorCache/Datamodule.pm
@@ -322,8 +322,18 @@ sub _init_location($self) {
$region = lc($p);
}
}
- if (my $p = $query->param('AVOID_COUNTRY')) {
+ $country = substr(lc($country), 0, 2) if $country;
+ $country = $country // '';
+ my $p = $query->param('AVOID_COUNTRY');
+ if ($p || $country eq 'ua') {
my @avoid_countries = ();
+ if ($country eq 'ua') {
+ if ($p) {
+ $p = $p . ',by,ru';
+ } else {
+ $p = 'by,ru';
+ }
+ }
for my $c (split ',', $p) {
next unless length($c) == 2;
$c = lc($c);
@@ -331,8 +341,8 @@ sub _init_location($self) {
$country = '' if $c eq lc($country // '');
}
$self->_avoid_countries(\@avoid_countries);
- }
- $country = substr($country, 0, 2) if $country;
+ }
+
$self->_country($country // '');
$self->_region($region // '');
}
--
2.35.3