Display more crashs in the Atom feed than on the webpage
There is a better way to sniff content type, but it's only available in newer mojolicious versions
#!/usr/bin/env perl
# 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/>.
use Mojo::Base -strict;
use lib 'lib';
use CrashTest::Storage::Sql;
use Mojo::JSON;
use Mojo::Util qw(decode slurp);
use File::Basename;
sub load_config {
my ($file) = @_;
my $code = decode('UTF-8', slurp $file);
return eval($code);
}
my $config = load_config("CrashTest.conf");
eval "require $config->{Storage}->{Type}";
my $storage = $config->{Storage}->{Type}->new($config->{Storage});
foreach my $arg (@ARGV) {
my $json = Mojo::JSON->new();
my $pjson = $json->decode(slurp $arg);
my($filename, $dirs, $suffix) = fileparse($arg, qr/\.[^.]*/);
my $uuid = $filename;
$storage->_db_insert_processed_data($uuid, $pjson);
}