copy_file_to_webdav_folder: Übergebenen Anhang-Name berücksichtigen
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Fri, 3 Dec 2021 13:29:42 +0000 (14:29 +0100)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Mon, 20 Dec 2021 10:21:59 +0000 (11:21 +0100)
SL/Common.pm
SL/Form.pm

index a0d54fe..15f8f7b 100644 (file)
@@ -593,8 +593,10 @@ sub copy_file_to_webdav_folder {
     return;
   }
 
+  $form->{attachment_filename} ||= $form->generate_attachment_filename;
+
   my $timestamp =  get_current_formatted_time();
-  my $new_file  =  File::Spec->catfile($form->{cwd}, $webdav_folder, $form->generate_attachment_filename());
+  my $new_file  =  File::Spec->catfile($form->{cwd}, $webdav_folder, $form->{attachment_filename});
   $new_file =~ s{(.*)\.}{$1$timestamp\.};
 
   if (!File::Copy::copy($current_file, $new_file)) {
index 29d9d6c..e8a3c0e 100644 (file)
@@ -857,6 +857,9 @@ sub parse_template {
   # therefore copy to webdav, even if we do not have the webdav feature enabled (just archive)
   my $copy_to_webdav =  $::instance_conf->get_webdav_documents && !$self->{preview} && $self->{tmpdir} && $self->{tmpfile} && $self->{type}
                         && $self->{type} ne 'statement';
+
+  $self->{attachment_filename} ||= $self->generate_attachment_filename;
+
   if ( $ext_for_format eq 'pdf' && $self->doc_storage_enabled ) {
     $self->append_general_pdf_attachments(filepath =>  $self->{tmpdir}."/".$self->{tmpfile},
                                           type     =>  $self->{type});
@@ -873,7 +876,6 @@ sub parse_template {
 
     if (!$self->{preview} && $self->{attachment_type} !~ m{^dunning} && $self->doc_storage_enabled)
     {
-      $self->{attachment_filename} ||= $self->generate_attachment_filename;
       $self->store_pdf($self);
     }
     $self->cleanup;
@@ -892,7 +894,6 @@ sub parse_template {
   }
 
   if ( !$self->{preview} && $ext_for_format eq 'pdf' && $self->{attachment_type} !~ m{^dunning} && $self->doc_storage_enabled) {
-    $self->{attachment_filename} ||= $self->generate_attachment_filename;
     my $file_obj = $self->store_pdf($self);
     $self->{print_file_id} = $file_obj->id if $file_obj;
   }