* Use ->update({...}) properly.

This commit is contained in:
Eelco Dolstra 2009-03-09 16:22:41 +00:00
parent 717625a5b9
commit 8725dc03ec
5 changed files with 19 additions and 49 deletions

View file

@ -175,9 +175,7 @@ sub restart : Chained('build') PathPart Args(0) {
($build->resultInfo->buildstatus == 3 || ($build->resultInfo->buildstatus == 3 ||
$build->resultInfo->buildstatus == 4); $build->resultInfo->buildstatus == 4);
$build->finished(0); $build->update({finished => 0, timestamp => time});
$build->timestamp(time());
$build->update;
$build->resultInfo->delete; $build->resultInfo->delete;

View file

@ -153,11 +153,9 @@ sub updateProject {
} else { # it's an existing jobset } else { # it's an existing jobset
$jobset = ($project->jobsets->search({name => $baseName}))[0]; $jobset = ($project->jobsets->search({name => $baseName}))[0];
die unless defined $jobset; die unless defined $jobset;
$jobset->name($jobsetName); $jobset->update(
$jobset->description($description); { name => $jobsetName, description => $description
$jobset->nixexprpath($nixExprPath); , nixexprpath => $nixExprPath, nixexprinput => $nixExprInput });
$jobset->nixexprinput($nixExprInput);
$jobset->update;
} }
my %inputNames; my %inputNames;
@ -189,9 +187,7 @@ sub updateProject {
} else { # it's an existing jobset } else { # it's an existing jobset
$input = ($jobset->jobsetinputs->search({name => $baseName2}))[0]; $input = ($jobset->jobsetinputs->search({name => $baseName2}))[0];
die unless defined $input; die unless defined $input;
$input->name($inputName); $input->update({name => $inputName, type => $inputType});
$input->type($inputType);
$input->update;
} }
# Update the values for this input. Just delete all the # Update the values for this input. Just delete all the

View file

@ -103,9 +103,9 @@ sub updateReleaseSet {
my $releaseSetName = trim $c->request->params->{name}; my $releaseSetName = trim $c->request->params->{name};
die "Invalid release set name: $releaseSetName" unless $releaseSetName =~ /^[[:alpha:]]\w*$/; die "Invalid release set name: $releaseSetName" unless $releaseSetName =~ /^[[:alpha:]]\w*$/;
$releaseSet->name($releaseSetName); $releaseSet->update(
$releaseSet->description(trim $c->request->params->{description}); { name => $releaseSetName
$releaseSet->update; , description => trim $c->request->params->{description} });
$releaseSet->releasesetjobs->delete_all; $releaseSet->releasesetjobs->delete_all;

View file

@ -30,6 +30,7 @@ sub doBuild {
if (!isValidPath($outPath)) { if (!isValidPath($outPath)) {
$isCachedBuild = 0; $isCachedBuild = 0;
# Do the build.
$startTime = time(); $startTime = time();
my $thisBuildFailed = 0; my $thisBuildFailed = 0;
@ -74,10 +75,7 @@ sub doBuild {
(my $step) = $db->resultset('BuildSteps')->search( (my $step) = $db->resultset('BuildSteps')->search(
{id => $build->id, type => 0, drvpath => $drvPath}, {}); {id => $build->id, type => 0, drvpath => $drvPath}, {});
die unless $step; die unless $step;
$step->busy(0); $step->update({busy => 0, status => 0, time => 0});
$step->status(0);
$step->stoptime(time);
$step->update;
}); });
} }
@ -89,12 +87,7 @@ sub doBuild {
(my $step) = $db->resultset('BuildSteps')->search( (my $step) = $db->resultset('BuildSteps')->search(
{id => $build->id, type => 0, drvpath => $drvPathStep}, {}); {id => $build->id, type => 0, drvpath => $drvPathStep}, {});
if ($step) { if ($step) {
die unless $step; $step->update({busy => 0, status => 1, errormsg => $4, stoptime => time});
$step->busy(0);
$step->status(1);
$step->errormsg($4);
$step->stoptime(time);
$step->update;
} else { } else {
$db->resultset('BuildSteps')->create( $db->resultset('BuildSteps')->create(
{ id => $build->id { id => $build->id
@ -133,10 +126,7 @@ sub doBuild {
(my $step) = $db->resultset('BuildSteps')->search( (my $step) = $db->resultset('BuildSteps')->search(
{id => $build->id, type => 1, outpath => $outPath}, {}); {id => $build->id, type => 1, outpath => $outPath}, {});
die unless $step; die unless $step;
$step->busy(0); $step->update({busy => 0, status => 0, stoptime => time});
$step->status(0);
$step->stoptime(time);
$step->update;
}); });
} }
@ -146,11 +136,7 @@ sub doBuild {
(my $step) = $db->resultset('BuildSteps')->search( (my $step) = $db->resultset('BuildSteps')->search(
{id => $build->id, type => 1, outpath => $outPath}, {}); {id => $build->id, type => 1, outpath => $outPath}, {});
die unless $step; die unless $step;
$step->busy(0); $step->update({busy => 0, status => 1, errormsg => $3, stoptime => time});
$step->status(1);
$step->errormsg($3);
$step->stoptime(time);
$step->update;
}); });
} }
@ -176,9 +162,7 @@ sub doBuild {
} }
$db->txn_do(sub { $db->txn_do(sub {
$build->finished(1); $build->({finished => 1, timestamp => time});
$build->timestamp(time());
$build->update;
my $logPath = "/nix/var/log/nix/drvs/" . basename $drvPath; my $logPath = "/nix/var/log/nix/drvs/" . basename $drvPath;
$logPath = undef unless -e $logPath; $logPath = undef unless -e $logPath;
@ -283,9 +267,7 @@ $db->txn_do(sub {
if ($build->schedulingInfo->busy != 0 && $build->schedulingInfo->locker != getppid) { if ($build->schedulingInfo->busy != 0 && $build->schedulingInfo->locker != getppid) {
die "build $buildId is already being built"; die "build $buildId is already being built";
} }
$build->schedulingInfo->busy(1); $build->schedulingInfo->update({busy => 1, locker => $$});
$build->schedulingInfo->locker($$);
$build->schedulingInfo->update;
$build->buildsteps->delete_all; $build->buildsteps->delete_all;
$build->buildproducts->delete_all; $build->buildproducts->delete_all;
}); });
@ -301,8 +283,6 @@ eval {
if ($@) { if ($@) {
warn $@; warn $@;
$db->txn_do(sub { $db->txn_do(sub {
$build->schedulingInfo->busy(0); $build->schedulingInfo->update({busy => 0, locker => $$});
$build->schedulingInfo->locker($$);
$build->schedulingInfo->update;
}); });
} }

View file

@ -84,8 +84,7 @@ sub fetchInputAlt {
} else { } else {
$timestamp = $cachedInput->timestamp; $timestamp = $cachedInput->timestamp;
$db->txn_do(sub { $db->txn_do(sub {
$cachedInput->lastseen(time); $cachedInput->update({lastseen => time});
$cachedInput->update;
}); });
} }
} }
@ -274,9 +273,7 @@ sub setJobsetError {
my ($jobset, $errorMsg) = @_; my ($jobset, $errorMsg) = @_;
eval { eval {
$db->txn_do(sub { $db->txn_do(sub {
$jobset->errormsg($errorMsg); $jobset->update({errormsg => $errorMsg, errortime => time});
$jobset->errortime(time);
$jobset->update;
}); });
}; };
} }
@ -316,8 +313,7 @@ sub checkJobSet {
my $inputInfo = {}; my $inputInfo = {};
$db->txn_do(sub { $db->txn_do(sub {
$jobset->lastcheckedtime(time); $jobset->update({lastcheckedtime => time});
$jobset->update;
}); });
# Fetch all values for all inputs. # Fetch all values for all inputs.