[Collab-qa-commits] r831 - svnbuildstat/trunk/lib/SvnBuildStat/Controller
goneri at alioth.debian.org
goneri at alioth.debian.org
Sun Apr 27 20:06:05 UTC 2008
Author: goneri
Date: 2008-04-27 20:06:05 +0000 (Sun, 27 Apr 2008)
New Revision: 831
Modified:
svnbuildstat/trunk/lib/SvnBuildStat/Controller/Controls.pm
Log:
more robust
Modified: svnbuildstat/trunk/lib/SvnBuildStat/Controller/Controls.pm
===================================================================
--- svnbuildstat/trunk/lib/SvnBuildStat/Controller/Controls.pm 2008-04-27 19:31:07 UTC (rev 830)
+++ svnbuildstat/trunk/lib/SvnBuildStat/Controller/Controls.pm 2008-04-27 20:06:05 UTC (rev 831)
@@ -45,7 +45,6 @@
my $dscuri = $changelogentry->dscuri;
-# print $dscuri."\n";
die unless $c->config->{path}->{weburi};
my $repositoryuri = $c->config->{path}->{weburi}."/static/files";
$dscuri =~ s/\@REPOSITORY_URL@/$repositoryuri/;
@@ -80,7 +79,9 @@
SELECT
changelogentry.id,
changelogentry.dscuri,
- build.id from build,
+ build.id
+FROM
+ build,
changelogentry
LEFT JOIN
qajob
@@ -91,31 +92,24 @@
WHERE
build.changelogentry_id=changelogentry.id
AND
- buildisok='1'
+ isbuildok='1'
ORDER BY
lastjobstart IS NOT NULL,
lastjobstart
LIMIT 1";
-# TODO improve the ORDER BY
my @array = $dbh->selectrow_array($request);
my $changelogentry_id = $array[0];
my $dscuri = $array[1];
my $build_id = $array[2];
my $cookie = int (rand(0xfffffff));
- die unless $changelogentry_id && $build_id;
+ die unless $changelogentry_id && $dscuri && $build_id;
my $changelogentry = $c->model('SvnBuildStat::Model::DB::Changelogentry')->search({id => $changelogentry_id})->first;
die unless $changelogentry;
die unless $c->config->{path}->{weburi};
- my $changesfile = bsd_glob($c->config->{path}->{staticdir}.'/files/'.$changelogentry->repositoryentry_id->repository_id->team_id->shortname.'/'.$changelogentry->repositoryentry_id->sourcepackage_id->name.'/'.$changelogentry->repositoryentry_id->changelogentry_id->id.'/build/'.$build_id."/deb/*.changes");
- my $changesuri = $c->config->{path}->{weburi}.'/static/files/'.$changelogentry->repositoryentry_id->repository_id->team_id->shortname.'/'.$changelogentry->repositoryentry_id->sourcepackage_id->name.'/'.$changelogentry->repositoryentry_id->changelogentry_id->id.'/build/'.$build_id."/deb/".basename($changesfile);
-# print $dscuri."\n";
- my $repositoryuri = $c->config->{path}->{weburi}."/static/files";
- $dscuri =~ s/\@REPOSITORY_URL@/$repositoryuri/;
- my $ret = "cookie=$cookie\n";
-
+ my $ret;
my $qajob;
if ($params->{target} eq 'source') {
@@ -124,6 +118,10 @@
changelogentry_id => $changelogentry_id,
build_id => undef,
);
+ $qajob->cookie($cookie);
+ $qajob->lastjobstart("NOW");
+ $qajob->update;
+
$ret .= "qajob_id=".$qajob->id."\ndsc=$dscuri\n";
} elsif ($params->{target} eq 'binary') {
@@ -133,15 +131,24 @@
changelogentry_id => $changelogentry_id,
build_id => $build_id,
);
+ $qajob->cookie($cookie);
+ $qajob->lastjobstart("NOW");
+ $qajob->update;
+ my $changesfile = bsd_glob($c->config->{path}->{staticdir}.'/files/'.$changelogentry->repositoryentry_id->repository_id->team_id->shortname.'/'.$changelogentry->repositoryentry_id->sourcepackage_id->name.'/'.$changelogentry->repositoryentry_id->changelogentry_id->id.'/build/'.$build_id."/deb/*.changes");
+ my $changesuri = $c->config->{path}->{weburi}.'/static/files/'.$changelogentry->repositoryentry_id->repository_id->team_id->shortname.'/'.$changelogentry->repositoryentry_id->sourcepackage_id->name.'/'.$changelogentry->repositoryentry_id->changelogentry_id->id.'/build/'.$build_id."/deb/".basename($changesfile);
+
$ret .= "qajob_id=".$qajob->id."\nchangesuri=".$changesuri."\n";
}
die unless $qajob;
- $qajob->cookie($cookie);
- $qajob->lastjobstart("NOW");
- $qajob->update;
+
+ my $repositoryuri = $c->config->{path}->{weburi}."/static/files";
+ $dscuri =~ s/\@REPOSITORY_URL@/$repositoryuri/;
+ $ret .= "cookie=$cookie\n";
+
+
$c->response->body($ret);
}
@@ -165,9 +172,14 @@
my $uploaddir = $c->config->{path}->{uploaddir}."/".$host->ip;
SvnBuildStat::Common::recurseMkdir($uploaddir);
my $upload = $c->request->upload('file');
+ if (!$upload || !$upload->filename) {
+ $c->response->body("ko ".$!);
+ return;
+ }
my $newfile = $uploaddir.'/'.basename($upload->filename);
if (!$upload->copy_to($newfile)) {
$c->response->body("ko ".$!);
+ return;
}
$c->response->body("ok");
More information about the Collab-qa-commits
mailing list