--- a/CrashTest.conf Sat Nov 24 23:16:50 2012 +0100
+++ b/CrashTest.conf Sat Apr 06 21:08:10 2013 +0200
@@ -2,6 +2,8 @@
DataDir => 'data/',
MinidumpStackwalkJSON => './stackwalker',
SymbolsPath => 'breakpad-debug-symbols/*',
+ Storage => "CrashTest::Storage::FileSystem",
+ DecodeQueue => "CrashTest::Decode::Queue::NoQueue",
ScmLinks => {
"svn:svn.example.org/testproject" => 'https://redmine.example.org/projects/testproject/repository/entry/<%= $scmpath =%>?rev=<%= $rev =%>#L<%= $line =%>',
},
--- a/CrashTest.pl Sat Nov 24 23:16:50 2012 +0100
+++ b/CrashTest.pl Sat Apr 06 21:08:10 2013 +0200
@@ -19,12 +19,21 @@
use Mojo::ByteStream 'b';
use Mojo::UserAgent;
use lib 'lib';
-use CrashTest::Storage::FileSystem;
my @valid_params = qw/Add-ons Distributor ProductName ReleaseChannel StartupTime UserID Version BuildID CrashTime Comments/;
my $config = plugin 'Config';
-my $storage = CrashTest::Storage::FileSystem->new($config->{DataDir});
+app->attr(storage => sub {
+ my $self = shift;
+ eval "require $config->{Storage}";
+ return $config->{Storage}->new($config->{DataDir});
+});
+
+app->attr(decode_queue => sub {
+ my $self = shift;
+ eval "require $config->{DecodeQueue}";
+ return $config->{DecodeQueue}->new($config);
+});
helper scm_file_link => sub {
my ($self, $file, $line) = @_;
@@ -70,13 +79,13 @@
# Upload form in DATA section
get '/' => sub {
my $self = shift;
- $self->stash(files => $storage->index());
+ $self->stash(files => $self->app->storage->index());
$self->render('index');
} => 'index';
get '/report/:uuid' => [ uuid => qr/[0-9a-fA-F-]+/ ] => sub {
my $self = shift;
- $self->stash(processed_data => $storage->get_processed_data($self->param('uuid')));
+ $self->stash(processed_data => $self->app->storage->get_processed_data($self->param('uuid')));
$self->render('report/crash');
} => 'report';
@@ -85,24 +94,16 @@
# save the dump in a file
my $file = $self->req->upload('upload_file_minidump');
+ my %paramshash = map { $_ => $self->req->param($_) } $self->req->param;
+
+ my $pjson = $self->app->decode_queue->decode($file, \%paramshash);
+
my ($uuid, $uuidstr);
UUID::generate($uuid);
UUID::unparse($uuid, $uuidstr);
- my $dmp_file = "/tmp/$uuidstr.dmp";
- $file->move_to($dmp_file);
- my $out = qx($config->{MinidumpStackwalkJSON} "$dmp_file" $config->{SymbolsPath} 2>/dev/null) or die $!;
-
- my $json = Mojo::JSON->new;
- my $pjson = $json->decode($out);
-
- # Create json for the params
- my %paramshash = map { $_ => $self->req->param($_) } $self->req->param;
- $pjson->{client_info} = \%paramshash;
-
- $storage->store_dump($uuidstr, $file);
- $storage->store_processed_data($uuidstr, $pjson);
- unlink $dmp_file if -w $dmp_file;
+ $self->app->storage->store_dump($uuidstr, $file);
+ $self->app->storage->store_processed_data($uuidstr, $pjson);
# reply
$self->render_text($pjson->{status});
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/CrashTest/Decode/Queue/NoQueue.pm Sat Apr 06 21:08:10 2013 +0200
@@ -0,0 +1,52 @@
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+package CrashTest::Decode::Queue::NoQueue;
+
+use File::Temp;
+
+use strict;
+use warnings;
+
+sub new {
+ my ($class, $config) = @_;
+ my $self = {};
+ $self->{config} = $config;
+ bless ($self, $class);
+ return $self;
+}
+
+sub config {
+ my ($self, $key) = @_;
+ return $self->{config}->{$key};
+}
+
+sub decode {
+ my ($self, $file, $paramshash) = @_;
+ my $fh = File::Temp->new(SUFFIX => '.dmp');
+ my $dmp_file = $fh->filename;
+ $file->move_to($dmp_file);
+
+ my $cmd = $self->config("MinidumpStackwalkJSON") . " $dmp_file " . $self->config("SymbolsPath");
+ my $out = qx($cmd 2>/dev/null) or die $!;
+
+ my $json = Mojo::JSON->new;
+ my $pjson = $json->decode($out);
+
+ # Create json for the params
+ $pjson->{client_info} = $paramshash;
+
+ return $pjson;
+}
+
+1;