diff --git a/CHANGES b/CHANGES index 1b4c268..e30eb2a 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +0.43.1 2023-02-22 17:19:04 +0100 Tobias Oetiker + + - make renderTemplate work, even when the destination folder does not exist + 0.43.0 2023-02-14 16:54:59 +0100 Tobias Oetiker - add display action which displays a report in a new window instead of providing a download diff --git a/lib/CallBackery.pm b/lib/CallBackery.pm index e8c244c..7ed47e3 100644 --- a/lib/CallBackery.pm +++ b/lib/CallBackery.pm @@ -38,7 +38,7 @@ use CallBackery::Database; use CallBackery::User; -our $VERSION = '0.43.0'; +our $VERSION = '0.43.1'; =head2 config diff --git a/lib/CallBackery/Controller/RpcService.pm b/lib/CallBackery/Controller/RpcService.pm index e6955ef..9cfa1f0 100644 --- a/lib/CallBackery/Controller/RpcService.pm +++ b/lib/CallBackery/Controller/RpcService.pm @@ -4,7 +4,6 @@ use Mojo::Base qw(Mojolicious::Plugin::Qooxdoo::JsonRpcController), -signatures,-async_await; use CallBackery::Exception qw(mkerror); use CallBackery::Translate qw(trm); -use CallBackery::User; use Scalar::Util qw(blessed weaken); use Mojo::JSON qw(encode_json decode_json from_json); use Syntax::Keyword::Try; diff --git a/lib/CallBackery/GuiPlugin/Abstract.pm b/lib/CallBackery/GuiPlugin/Abstract.pm index 8150df9..7183b7e 100644 --- a/lib/CallBackery/GuiPlugin/Abstract.pm +++ b/lib/CallBackery/GuiPlugin/Abstract.pm @@ -500,7 +500,7 @@ has homeDir => sub { sub renderTemplate{ my $self = shift; my $template = shift; - my $destination = shift; + my $destination = Mojo::File->new(shift); $self->log->debug('['.$self->name.'] processing template '.$template); my $newData = $self->template->render($self->app->home->rel_file('templates/system/'.$template)->slurp); if (-r $destination){ @@ -509,13 +509,15 @@ sub renderTemplate{ return 0 } } + my $dir = $destination->dirname; + if (not -d $dir){ + Mojo::File->new($dir)->make_path({mode => 755}); + } $self->log->debug('['.$self->name."] writing $destination\n$newData"); eval { local $SIG{__DIE__}; - open my $fh, '>',$destination; - print $fh $newData; - close $fh; + $destination->spurt($newData); }; if ($@){ if (blessed $@ and $@->isa('autodie::exception')){