From 030c808c88809c79d750833b30a09ea1e136e372 Mon Sep 17 00:00:00 2001 From: Andrii Nikitin Date: Fri, 24 Nov 2023 12:10:48 +0100 Subject: [PATCH] fix: mirrors with capability declaraion might disappear in /rest/server --- lib/MirrorCache/Schema/Result/Server.pm | 8 +++++++- t/environ/01-smoke-mirror-country-only-remote.sh | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/MirrorCache/Schema/Result/Server.pm b/lib/MirrorCache/Schema/Result/Server.pm index e5b51218..48ad2e08 100644 --- a/lib/MirrorCache/Schema/Result/Server.pm +++ b/lib/MirrorCache/Schema/Result/Server.pm @@ -62,7 +62,13 @@ __PACKAGE__->has_many( __PACKAGE__->has_many( "server_capability_declaration", "MirrorCache::Schema::Result::ServerCapabilityDeclaration", - { "foreign.server_id" => "self.id" }, + sub { + my $args = shift; + return { + "$args->{foreign_alias}.server_id" => { -ident => "$args->{self_alias}.id" }, + "$args->{foreign_alias}.extra" => { '=', 'region' }, + }; + }, { cascade_copy => 0, cascade_delete => 0, join_type => 'left' }, ); diff --git a/t/environ/01-smoke-mirror-country-only-remote.sh b/t/environ/01-smoke-mirror-country-only-remote.sh index 9e201898..49845b90 100755 --- a/t/environ/01-smoke-mirror-country-only-remote.sh +++ b/t/environ/01-smoke-mirror-country-only-remote.sh @@ -55,4 +55,6 @@ $mc/curl -I /download/folder1/file1.1.dat?COUNTRY=dk | grep -C10 302 | grep "$($ echo but ap8 still serves uk $mc/curl -I /download/folder1/file1.1.dat?COUNTRY=uk | grep -C10 302 | grep "$($ap8/print_address)" +$mc/curl /rest/server | grep "$($ap8/print_address)" + echo success