From 5659d2982c310cd87b21daeda87a4ec8be796358 Mon Sep 17 00:00:00 2001 From: Cole Helbling Date: Tue, 30 Nov 2021 12:37:17 -0800 Subject: [PATCH] Hydra/Controller/Root: remove deprecated LocalRegex 11:38:20 hydra-server.1 | DEPRECATION WARNING: The Regex dispatch type is deprecated. 11:38:20 hydra-server.1 | It is recommended that you convert Regex and LocalRegex 11:38:20 hydra-server.1 | methods to Chained methods. at /nix/store/aa6gw57fnahd4824pbhmvcs0jlypmynq-hydra-perl-deps/lib/perl5/site_perl/5.32.1/Catalyst/DispatchType/Regex.pm line 210. --- flake.nix | 1 - src/lib/Hydra/Controller/Root.pm | 11 +++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/flake.nix b/flake.nix index b93ad4aa..5d76568a 100644 --- a/flake.nix +++ b/flake.nix @@ -429,7 +429,6 @@ CatalystAuthenticationStoreDBIxClass CatalystAuthenticationStoreLDAP CatalystDevel - CatalystDispatchTypeRegex CatalystPluginAccessLog CatalystPluginAuthorizationRoles CatalystPluginCaptcha diff --git a/src/lib/Hydra/Controller/Root.pm b/src/lib/Hydra/Controller/Root.pm index df178df4..01bb7b44 100644 --- a/src/lib/Hydra/Controller/Root.pm +++ b/src/lib/Hydra/Controller/Root.pm @@ -15,6 +15,9 @@ use JSON; use List::Util qw[min max]; use List::MoreUtils qw{any}; use Net::Prometheus; +use Types::Standard qw/StrMatch/; + +use constant NARINFO_REGEX => qr{^([a-z0-9]{32})\.narinfo$}; # Put this controller at top-level. __PACKAGE__->config->{namespace} = ''; @@ -349,17 +352,17 @@ sub nix_cache_info :Path('nix-cache-info') :Args(0) { } -sub narinfo :LocalRegex('^([a-z0-9]+).narinfo$') :Args(0) { - my ($self, $c) = @_; +sub narinfo :Path :Args(StrMatch[NARINFO_REGEX]) { + my ($self, $c, $narinfo) = @_; if (!isLocalStore) { notFound($c, "There is no binary cache here."); } else { - my $hash = $c->req->captures->[0]; + my ($hash) = $narinfo =~ NARINFO_REGEX; - die if length($hash) != 32; + die("Hash length was not 32") if length($hash) != 32; my $path = queryPathFromHashPart($hash); if (!$path) {