Improve cli-restore file read (#1833)

This commit is contained in:
Xavier Guimard 2019-07-01 16:45:40 +02:00
parent 17b84e3eb8
commit 364fb8b627
2 changed files with 4 additions and 4 deletions

View File

@ -213,9 +213,10 @@ sub restore {
}
else {
die "Unable to read $file" unless ( -r $file );
open( my $f, $file );
open( my $f, $file ) or die $!;
$conf = join '', <$f>;
close $f;
die "Empty or malformed file $file" unless ( $conf =~ /\w/s );
}
my $res = $self->_post( '/confs/raw', '', IO::String->new($conf),
'application/json', length($conf) );
@ -265,8 +266,7 @@ sub _setKey {
sub _save {
my ( $self, $new ) = @_;
require Lemonldap::NG::Manager::Conf::Parser;
my $parser = Lemonldap::NG::Manager::Conf::Parser->new(
{
my $parser = Lemonldap::NG::Manager::Conf::Parser->new( {
newConf => $new,
refConf => $self->mgr->currentConf,
req => $self->req

View File

@ -9,7 +9,7 @@ use strict;
use_ok('Lemonldap::NG::Common::Cli');
use_ok('Lemonldap::NG::Manager::Cli');
foreach (qw(2 3)) {
foreach ( 2 .. $tests - 3 ) {
unlink "t/conf/lmConf-$_.json";
}