foreach my $item (qw(tmpdir tmpfile type)){
next if $form->{$item};
$::lxdebug->message(LXDebug::WARN(), 'Missing parameter:' . $item);
- $::form->error($::locale->text("Missing parameter for WebDAV file copy"));
+ $::lxdebug->leave_sub();
+ return $::locale->text("Missing parameter for WebDAV file copy");
}
my ($webdav_folder, $document_name) = get_webdav_folder($form);
if (! $webdav_folder){
- $::lxdebug->leave_sub();
$::lxdebug->message(LXDebug::WARN(), 'Cannot check correct WebDAV folder');
- $::form->error($::locale->text("Cannot check correct WebDAV folder"));
- return undef;
+ $::lxdebug->leave_sub();
+ return $::locale->text("Cannot check correct WebDAV folder")
}
$complete_path = File::Spec->catfile($form->{cwd}, $webdav_folder);
chdir($current_dir);
}
- opendir my $dh, $complete_path or die "Could not open $complete_path: $!";
+ my $dh;
+ if (!opendir $dh, $complete_path) {
+ $::lxdebug->leave_sub();
+ return "Could not open $complete_path: $!";
+ }
my ($newest_name, $newest_time);
while ( defined( my $file = readdir( $dh ) ) ) {
if (!File::Copy::copy($current_file, $new_file)) {
$::lxdebug->message(LXDebug::WARN(), "Copy file from $current_file to $new_file failed: $ERRNO");
- $::form->error($::locale->text("Copy file from #1 to #2 failed: #3", $current_file, $new_file, $ERRNO));
+ $::lxdebug->leave_sub();
+ return $::locale->text("Copy file from #1 to #2 failed: #3", $current_file, $new_file, $ERRNO);
}
$::lxdebug->leave_sub();
}
if ($self->{media} eq 'file') {
copy(join('/', $self->{cwd}, $userspath, $self->{tmpfile}), $out =~ m|^/| ? $out : join('/', $self->{cwd}, $out)) if $template->uses_temp_file;
- Common::copy_file_to_webdav_folder($self) if $copy_to_webdav;
+
+ if ($copy_to_webdav) {
+ my $error = Common::copy_file_to_webdav_folder($self);
+ chdir("$self->{cwd}");
+ $self->error($error) if $error;
+ }
+
if (!$self->{preview} && $self->doc_storage_enabled)
{
$self->{attachment_filename} ||= $self->generate_attachment_filename;
return;
}
- Common::copy_file_to_webdav_folder($self) if $copy_to_webdav;
+ if ($copy_to_webdav) {
+ my $error = Common::copy_file_to_webdav_folder($self);
+ chdir("$self->{cwd}");
+ $self->error($error) if $error;
+ }
if ( !$self->{preview} && $ext_for_format eq 'pdf' && $self->doc_storage_enabled) {
$self->{attachment_filename} ||= $self->generate_attachment_filename;