Generate *.narinfo files on the fly to support the binary cache substituter
This commit is contained in:
@ -195,9 +195,28 @@ sub nar :Local :Args(1) {
|
||||
}
|
||||
|
||||
|
||||
sub narinfo :Path('*.narinfo') {
|
||||
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.");
|
||||
}
|
||||
|
||||
|
||||
sub narinfo :LocalRegex('^([a-z0-9]+).narinfo$') :Args(0) {
|
||||
my ($self, $c) = @_;
|
||||
$c->stash->{current_view} = 'NixInfo';
|
||||
my $hash = $c->req->captures->[0];
|
||||
$c->stash->{storePath} = hashToPath($c, $hash);
|
||||
$c->stash->{current_view} = 'NARInfo';
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user