From da960b507dfa6a0b807b934fc8e73cff9ced6468 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 18 Jul 2012 23:14:17 +0200 Subject: [PATCH] Use queryPathFromHashPart to look up binary cache requests efficiently --- src/lib/Hydra/Controller/Root.pm | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/lib/Hydra/Controller/Root.pm b/src/lib/Hydra/Controller/Root.pm index fadb1f20..2e970625 100644 --- a/src/lib/Hydra/Controller/Root.pm +++ b/src/lib/Hydra/Controller/Root.pm @@ -198,17 +198,9 @@ sub nar :Local :Args(1) { sub hashToPath { my ($c, $hash) = @_; die if length($hash) != 32; - # FIXME: doing a glob is very inefficient. Should do a database - # lookup. - my @glob = glob("/nix/store/$hash*"); - foreach my $storePath (@glob) { - if (isValidPath($storePath)) { - print STDERR "FOUND: $hash -> $storePath\n"; - return $storePath; - } - #return $storePath if isValidPath($storePath); - } - notFound($c, "Store path with hash ‘$hash’ does not exist."); + my $path = queryPathFromHashPart($hash); + notFound($c, "Store path with hash ‘$hash’ does not exist.") unless $path; + return $path; }