diff -r e408da1419cd -r 0ebef32c34af bin/fs_to_db.pl --- a/bin/fs_to_db.pl Sun Sep 27 22:45:40 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -#!/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 . - -use Mojo::Base -strict; -use lib 'lib'; - -use Mojo::JSON qw/decode_json/; -use Mojo::Util qw/decode slurp/; -use Mojo::Loader qw/load_class/; -use File::Basename; -use Mojolicious; -use Mojo::Home; - -if(scalar @ARGV == 0) { - say "Usage: $0 "; - exit 1; -} - -sub load_config { - my $app = Mojolicious->new; - $app->home(Mojo::Home->new("$FindBin::Bin/../")); - $app->moniker("CrashTest"); - return $app->plugin('Config'); -} - -my $config = load_config(); - -my $storage_class = $config->{Storage}->{Type}; -if (my $e = load_class($storage_class)) { - die ref $e ? "Exception: $e" : 'Not found!'; -} - -my $storage = $storage_class->new(config => $config->{Storage}); - -foreach my $arg (@ARGV) { - eval { - my $pjson = decode_json(slurp $arg); - - my($filename, $dirs, $suffix) = fileparse($arg, qr/\.[^.]*/); - - my $uuid = $filename; - $storage->_db_insert_processed_data($uuid, $pjson); - }; - warn $@ if $@; -}