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 { sub hashToPath {
my ($c, $hash) = @_; my ($c, $hash) = @_;
die if length($hash) != 32; die if length($hash) != 32;
# FIXME: doing a glob is very inefficient. Should do a database my $path = queryPathFromHashPart($hash);
# lookup. notFound($c, "Store path with hash $hash does not exist.") unless $path;
my @glob = glob("/nix/store/$hash*"); return $path;
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.");
} }