Use queryPathFromHashPart to look up binary cache requests efficiently

This commit is contained in:
Eelco Dolstra 2012-07-18 23:14:17 +02:00
parent 544f2f2503
commit da960b507d

View file

@ -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;
}