Prevent inputs from being garbage collected during evaluation

There is still a tiny window between the calls to nix-prefetch-* and
addTempRoot. This could be eliminated by adding a "-o" option to
nix-prefetch-*, or by not using those scripts at all (and use
addToStore directly).
This commit is contained in:
Eelco Dolstra
2015-10-09 12:50:23 +02:00
parent d959afebe1
commit ca58e97691
4 changed files with 17 additions and 0 deletions

View File

@@ -36,6 +36,8 @@ sub fetchInput {
(my $cachedInput) = $self->{db}->resultset('CachedBazaarInputs')->search(
{uri => $uri, revision => $revision});
addTempRoot($cachedInput->storepath) if defined $cachedInput;
if (defined $cachedInput && isValidPath($cachedInput->storepath)) {
$storePath = $cachedInput->storepath;
$sha256 = $cachedInput->sha256hash;
@@ -53,6 +55,9 @@ sub fetchInput {
($sha256, $storePath) = split ' ', $stdout;
# FIXME: time window between nix-prefetch-bzr and addTempRoot.
addTempRoot($storePath);
txn_do($self->{db}, sub {
$self->{db}->resultset('CachedBazaarInputs')->create(
{ uri => $uri