From 9b0a9214762dafdc3e0313d8d75e0fe8ecb13fb0 Mon Sep 17 00:00:00 2001 From: "G. Richardson" Date: Tue, 19 Jun 2012 18:50:02 +0200 Subject: [PATCH] =?utf8?q?Bug=201926=20-=20Zuf=C3=A4lliger=20Dateiname=20f?= =?utf8?q?=C3=BCr=20PDF=20Spooldateien?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Beim Erstellen der Spooldatei beim Warteschlangendruck den Dateinamen per File::Temp::tempfile erstellen. Die bisherige Kombination aus time und PID hat PDF-Dateien überschrieben, wenn zwei Spooldateien in der gleichen Sekunde erstellt wurden. Beispiel alter Spoolname: 134012447722563.pdf Beispiel neuer Spoolname: kivitendo-spoolJKuGZM.pdf --- bin/mozilla/io.pl | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index fa46e646b..e25f963a8 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -1535,22 +1535,31 @@ sub print_form { my %queued = map { s|.*/|| } split / /, $form->{queued}; my $filename; + my $suffix = ($form->{postscript}) ? '.ps' : '.pdf'; if ($filename = $queued{ $form->{formname} }) { $form->{queued} =~ s/\Q$form->{formname} $filename\E//; unlink $::lx_office_conf{paths}->{spool} . "/$filename"; $filename =~ s/\..*$//g; + $filename .= $suffix; + $form->{OUT} = $::lx_office_conf{paths}->{spool} . "/$filename"; + $form->{OUT_MODE} = '>'; } else { - $filename = time; - $filename .= $$; + my $temp_fh; + ($temp_fh, $filename) = File::Temp::tempfile( + 'kivitendo-spoolXXXXXX', + SUFFIX => "$suffix", + DIR => $::lx_office_conf{paths}->{spool}, + ); + close $temp_fh; + $form->{OUT} = "$filename"; + # use >> for OUT_MODE because file is already created by File::Temp + $form->{OUT_MODE} = '>>'; + # strip directory so that only filename is stored in table status + ($filename) = $filename =~ /^$::lx_office_conf{paths}->{spool}\/(.*)/; } - $filename .= ($form->{postscript}) ? '.ps' : '.pdf'; - $form->{OUT} = $::lx_office_conf{paths}->{spool} . "/$filename"; - $form->{OUT_MODE} = '>'; - # add type $form->{queued} .= " $form->{formname} $filename"; - $form->{queued} =~ s/^ //; } my $queued = $form->{queued}; -- 2.20.1