# HG changeset patch # User Vincent Tondellier # Date 1498079502 -7200 # Node ID 6b56182fd4919f7c649fd99539a6d193d531ca22 # Parent 0bbbadd5d9ea8082b897f12f3b8f08f70b8d8095 The "stretch" commit. Fix deprecation warnings with Mojolicious 7.21 Require Mojolicious 7.15 for Mojo::File support diff -r 0bbbadd5d9ea -r 6b56182fd491 dist.ini --- a/dist.ini Sun Apr 02 14:36:18 2017 +0200 +++ b/dist.ini Wed Jun 21 23:11:42 2017 +0200 @@ -30,7 +30,7 @@ format = %-9v %{yyyy-MM-dd}d [Prereqs] -Mojolicious = 7.00 +Mojolicious = 7.15 Mojolicious::Plugin::BootstrapPagination = 0.12 Mojolicious::Plugin::InstallablePaths = 0.04 UUID = 0.0.3 diff -r 0bbbadd5d9ea -r 6b56182fd491 lib/CrashTest/Command/get_trace.pm --- a/lib/CrashTest/Command/get_trace.pm Sun Apr 02 14:36:18 2017 +0200 +++ b/lib/CrashTest/Command/get_trace.pm Wed Jun 21 23:11:42 2017 +0200 @@ -16,9 +16,7 @@ use Mojo::Base 'Mojolicious::Command'; use Mojo::JSON::MaybeXS; use Mojo::JSON qw/decode_json/; -use Mojo::Util qw/slurp/; -use File::Spec::Functions qw/catdir catfile/; -use File::Basename; +use Mojo::File qw/path/; use CrashTest::Model::Thread; use CrashTest::Plugin::CrashSignatureExtractor::C_Cpp; @@ -40,7 +38,7 @@ } foreach my $jsonfile(@args) { - my $j = decode_json(slurp($jsonfile)); + my $j = decode_json(path($jsonfile)->slurp); my $raw_thread = $j->{threads}->[$j->{crashing_thread}->{threads_index}]; my $thread = CrashTest::Model::Thread->new($raw_thread); diff -r 0bbbadd5d9ea -r 6b56182fd491 lib/CrashTest/Command/insert.pm --- a/lib/CrashTest/Command/insert.pm Sun Apr 02 14:36:18 2017 +0200 +++ b/lib/CrashTest/Command/insert.pm Wed Jun 21 23:11:42 2017 +0200 @@ -16,9 +16,7 @@ use Mojo::Base 'Mojolicious::Command'; use Mojo::JSON::MaybeXS; use Mojo::JSON qw/decode_json/; -use Mojo::Util qw/slurp/; -use File::Spec::Functions qw/catdir catfile/; -use File::Basename; +use Mojo::File qw/path/; # Short description has description => 'Insert crash'; @@ -37,15 +35,17 @@ } foreach my $jsonfile(@args) { - my ($uuid,$path,$suffix) = fileparse($jsonfile, qw/.json/); + my $path = path($jsonfile); + my $uuid = $path->basename('.json'); + my $dmp_file = $path->dirname->child("$uuid.dmp"); my $dmp = undef; - if(-e catfile($path, "$uuid.dmp")) { - $dmp = slurp(catfile($path, "$uuid.dmp")); + if(-e $dmp_file) { + $dmp = $dmp_file->slurp; } eval { - my $pjson = decode_json(slurp(catfile($path, "$uuid.json"))); + my $pjson = decode_json($path->slurp); $self->app->crash_reports->create($uuid, $pjson, $pjson->{client_info}, $dmp); }; warn $@ if $@; diff -r 0bbbadd5d9ea -r 6b56182fd491 lib/CrashTest/Command/update.pm --- a/lib/CrashTest/Command/update.pm Sun Apr 02 14:36:18 2017 +0200 +++ b/lib/CrashTest/Command/update.pm Wed Jun 21 23:11:42 2017 +0200 @@ -16,9 +16,7 @@ use Mojo::Base 'Mojolicious::Command'; use Mojo::JSON::MaybeXS; use Mojo::JSON qw/decode_json/; -use Mojo::Util qw/slurp/; -use File::Spec::Functions qw/catdir catfile/; -use File::Basename; +use Mojo::File qw/path/; # Short description has description => 'Update crash'; @@ -37,15 +35,17 @@ } foreach my $jsonfile(@args) { - my ($uuid,$path,$suffix) = fileparse($jsonfile, qw/.json/); + my $path = path($jsonfile); + my $uuid = $path->basename('.json'); + my $dmp_file = $path->dirname->child("$uuid.dmp"); my $dmp = undef; - if(-e catfile($path, "$uuid.dmp")) { - $dmp = slurp(catfile($path, "$uuid.dmp")); + if(-e $dmp_file) { + $dmp = $dmp_file->slurp; } eval { - my $pjson = decode_json(slurp(catfile($path, "$uuid.json"))); + my $pjson = decode_json($path->slurp); $self->app->crash_reports->update($uuid, $pjson, $pjson->{client_info}, $dmp); }; warn $@ if $@; diff -r 0bbbadd5d9ea -r 6b56182fd491 lib/CrashTest/Plugin/Storage/File.pm --- a/lib/CrashTest/Plugin/Storage/File.pm Sun Apr 02 14:36:18 2017 +0200 +++ b/lib/CrashTest/Plugin/Storage/File.pm Wed Jun 21 23:11:42 2017 +0200 @@ -38,10 +38,9 @@ package CrashTest::Plugin::Storage::File::Model::CrashReport; use Mojo::Base -base; -use Mojo::Util qw/slurp spurt/; use Mojo::JSON::MaybeXS; use Mojo::JSON qw/encode_json decode_json/; -use File::Spec; +use Mojo::File qw/path/; has [ qw/instance app config extra_columns data_path/ ]; @@ -56,15 +55,23 @@ sub create { my ($self, $uuid, $pjson, $client_info, $dmp_file) = @_; - $self->_store_dump($uuid, slurp($dmp_file)); + if(defined($dmp_file) && -e $dmp_file) { + $self->_store_dump($uuid, path($dmp_file)->slurp); + } + $self->_store_processed_data($uuid, $pjson, $client_info); +} + +sub update { + my ($self, $uuid, $pjson, $client_info, $dmp_file) = @_; + $self->_store_processed_data($uuid, $pjson, $client_info); } sub get_processed_data { my ($self, $uuid) = @_; - my $jsonfilename = File::Spec->catfile($self->data_path, "$uuid.json"); - my $json_content = slurp($jsonfilename) or die $!; + my $jsonfilename = path($self->data_path, "$uuid.json"); + my $json_content = $jsonfilename->slurp or die $!; my $processed_data = decode_json($json_content); @@ -77,10 +84,10 @@ # Create json for the params $pjson->{client_info} = $client_info; - my $jsonfilename = File::Spec->catfile($self->data_path, "$uuid.json"); - my $dmpfilename = File::Spec->catfile($self->data_path, "$uuid.dmp"); + my $jsonfilename = path($self->data_path, "$uuid.json"); + my $dmpfilename = path($self->data_path, "$uuid.dmp"); - spurt(encode_json($pjson), $jsonfilename) or die $!; + $jsonfilename->spurt(encode_json($pjson)) or die $!; # Set time of the .dmp to the CrashTime my $crashtime = $pjson->{client_info}->{CrashTime}; @@ -92,11 +99,13 @@ sub _store_dump { my ($self, $uuid, $dmp_content) = @_; - my $dmp_file = File::Spec->catfile($self->data_path, "$uuid.dmp"); - my $fh = IO::File->new($dmp_file, "w") or die($!); - $fh->binmode; - print $fh $dmp_content; - undef $fh; + my $dmp_file = path($self->data_path, "$uuid.dmp"); + if(! -e $dmp_file) { + my $fh = IO::File->new($dmp_file, "w") or die($!); + $fh->binmode; + print $fh $dmp_content; + undef $fh; + } } 1;