Improve cli-restore file read (#1833)
This commit is contained in:
parent
17b84e3eb8
commit
364fb8b627
|
@ -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
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user