CrashTest.pl
changeset 19 300b902b5461
parent 17 c91535b1db3e
child 23 e621317229f7
equal deleted inserted replaced
18:60db1090095b 19:300b902b5461
    23 my @valid_params = qw/Add-ons Distributor ProductName ReleaseChannel StartupTime UserID Version BuildID CrashTime Comments/;
    23 my @valid_params = qw/Add-ons Distributor ProductName ReleaseChannel StartupTime UserID Version BuildID CrashTime Comments/;
    24 my $config = plugin 'Config';
    24 my $config = plugin 'Config';
    25 
    25 
    26 app->attr(storage => sub {
    26 app->attr(storage => sub {
    27     my $self = shift;
    27     my $self = shift;
    28     eval "require $config->{Storage}";
    28     eval "require $config->{Storage}->{Type}";
    29     return $config->{Storage}->new($config->{DataDir});
    29     return $config->{Storage}->{Type}->new($config->{Storage});
    30 });
    30 });
    31 
    31 
    32 app->attr(decode_queue => sub {
    32 app->attr(decode_queue => sub {
    33     my $self = shift;
    33     my $self = shift;
    34     eval "require $config->{DecodeQueue}";
    34     eval "require $config->{DecodeQueue}->{Type}";
    35     return $config->{DecodeQueue}->new($config);
    35     return $config->{DecodeQueue}->{Type}->new($config->{DecodeQueue}, $config->{Dumper}, app->storage);
    36 });
    36 });
    37 
    37 
    38 helper scm_file_link => sub {
    38 helper scm_file_link => sub {
    39     my ($self, $file, $line) = @_;
    39     my ($self, $file, $line) = @_;
    40 
    40 
    74         $short_signature = "$1()$2";
    74         $short_signature = "$1()$2";
    75     }
    75     }
    76     return b($self->t(span => (title => $signature, class => "shortened-signature") => $short_signature));
    76     return b($self->t(span => (title => $signature, class => "shortened-signature") => $short_signature));
    77 };
    77 };
    78 
    78 
    79 # Upload form in DATA section
       
    80 get '/' => sub {
    79 get '/' => sub {
    81     my $self = shift;
    80     my $self = shift;
    82     $self->stash(files => $self->app->storage->index());
    81     $self->stash(files => $self->app->storage->index());
    83     $self->render('index');
    82     $self->render('index');
    84 } => 'index';
    83 } => 'index';
    94 
    93 
    95     # save the dump in a file
    94     # save the dump in a file
    96     my $file = $self->req->upload('upload_file_minidump');
    95     my $file = $self->req->upload('upload_file_minidump');
    97     my %paramshash = map { $_ => $self->req->param($_) } $self->req->param;
    96     my %paramshash = map { $_ => $self->req->param($_) } $self->req->param;
    98 
    97 
    99     my $pjson = $self->app->decode_queue->decode($file, \%paramshash);
       
   100 
       
   101     my ($uuid, $uuidstr);
    98     my ($uuid, $uuidstr);
   102     UUID::generate($uuid);
    99     UUID::generate($uuid);
   103     UUID::unparse($uuid, $uuidstr);
   100     UUID::unparse($uuid, $uuidstr);
   104 
   101     my $pjson = $self->app->decode_queue->decode($file, \%paramshash, $uuidstr);
   105     $self->app->storage->store_dump($uuidstr, $file);
       
   106     $self->app->storage->store_processed_data($uuidstr, $pjson);
       
   107 
   102 
   108     # reply
   103     # reply
   109     $self->render_text($pjson->{status});
   104     $self->render_text($pjson->{status});
   110 };
   105 };
   111 
   106