--- 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});