X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FCommon.pm;h=33d4d41cf48705c563500b6defac83667a66ae7f;hb=37be5dfe10abacf6349f94c93d0f0abe1f0ca86e;hp=127209a7ff7975e56a521a96fc7beef70e215783;hpb=03d3d025ea4c8bea085fc7cdf1fe7be0b513eb63;p=kivitendo-erp.git diff --git a/SL/Common.pm b/SL/Common.pm index 127209a7f..33d4d41cf 100644 --- a/SL/Common.pm +++ b/SL/Common.pm @@ -623,6 +623,16 @@ sub copy_file_to_webdav_folder { } $complete_path = File::Spec->catfile($form->{cwd}, $webdav_folder); + + # maybe the path does not exist (automatic printing), see #2446 + if (!-d $complete_path) { + # we need a chdir and restore old dir + my $current_dir = POSIX::getcwd(); + chdir("$form->{cwd}"); + mkdir_with_parents($webdav_folder); + chdir($current_dir); + } + opendir my $dh, $complete_path or die "Could not open $complete_path: $!"; my ($newest_name, $newest_time); @@ -647,7 +657,7 @@ sub copy_file_to_webdav_folder { my $timestamp = get_current_formatted_time(); my $new_file = File::Spec->catfile($form->{cwd}, $webdav_folder, $form->generate_attachment_filename()); - $new_file =~ s/\./$timestamp\./; + $new_file =~ s{(.*)\.}{$1$timestamp\.}; if (!File::Copy::copy($current_file, $new_file)) { $::lxdebug->message(LXDebug::WARN(), "Copy file from $current_file to $new_file failed: $ERRNO");