freeside/FS/FS cust_bill.pm,1.41.2.49,1.41.2.50
ivan
ivan at pouncequick.420.am
Wed May 26 04:11:14 PDT 2004
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory pouncequick:/tmp/cvs-serv28461
Modified Files:
Tag: FREESIDE_1_4_BRANCH
cust_bill.pm
Log Message:
use File::Temp for filenames and store the temp files in cache.datasrc instead of /tmp
Index: cust_bill.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill.pm,v
retrieving revision 1.41.2.49
retrieving revision 1.41.2.50
diff -u -d -r1.41.2.49 -r1.41.2.50
--- cust_bill.pm 26 May 2004 10:38:45 -0000 1.41.2.49
+++ cust_bill.pm 26 May 2004 11:11:12 -0000 1.41.2.50
@@ -13,6 +13,7 @@
use Mail::Internet 1.44;
use Mail::Header;
use Text::Template;
+use File::Temp;
use FS::UID qw( datasrc );
use FS::Record qw( qsearch qsearchs );
use FS::cust_main;
@@ -1505,17 +1506,17 @@
$var;
}
- my $dir = '/tmp'; #! /usr/local/etc/freeside/invoices.datasrc/
- my $unique = int(rand(2**31)); #UGH... use File::Temp or something
-
- chdir($dir);
- my $file = $self->invnum. ".$unique";
-
- open(TEX,">$file.tex") or die "can't open $file.tex: $!\n";
- print TEX join("\n", @filled_in ), "\n";
- close TEX;
+ my $dir = $FS::UID::conf_dir. "cache.". $FS::UID::datasrc;
+ my $fh = new File::Temp( TEMPLATE => 'invoice.'. $self->invnum. '.XXXXXXXX',
+ DIR => $dir
+ SUFFIX => '.tex',
+ UNLINK => 0,
+ ) or die "can't open temp file: $!\n";
+ print $fh join("\n", @filled_in ), "\n";
+ close $fh;
- return $file;
+ $fh->filename =~ /^(.*).tex$/ or die "unparsable filename: ". $fh->filename;
+ return $1;
}
@@ -1535,6 +1536,9 @@
my $file = $self->print_latex(@_);
+ my $dir = $FS::UID::conf_dir. "cache.". $FS::UID::datasrc;
+ chdir($dir);
+
system("pslatex $file.tex >/dev/null 2>&1") == 0
or die "pslatex failed: $!";
system("pslatex $file.tex >/dev/null 2>&1") == 0
@@ -1574,6 +1578,9 @@
my $self = shift;
my $file = $self->print_latex(@_);
+
+ my $dir = $FS::UID::conf_dir. "cache.". $FS::UID::datasrc;
+ chdir($dir);
#system('pdflatex', "$file.tex");
#system('pdflatex', "$file.tex");
More information about the freeside-commits
mailing list