[X2Go-Commits] [cups-x2go] 07/07: cups-x2go: don't use unlink() explicitly.

git-admin at x2go.org git-admin at x2go.org
Wed Jun 17 20:15:24 CEST 2015


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch master
in repository cups-x2go.

commit d2b4c322092dd56b4f5eb9c9c810c413868b1722
Author: Mihai Moldovan <ionic at ionic.de>
Date:   Wed Jun 17 20:08:16 2015 +0200

    cups-x2go: don't use unlink() explicitly.
    
    Trust File::Temp and our END block to clean up correctly.
---
 cups-x2go        |   11 +++++++----
 debian/changelog |    2 ++
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/cups-x2go b/cups-x2go
index 2b8e492..404d96f 100755
--- a/cups-x2go
+++ b/cups-x2go
@@ -206,6 +206,7 @@ my $need_ps_file_cleanup = 0;
 if (!$psFile)
 {
 	$need_ps_file_cleanup = 1;
+
 	my ($tfh, $tempFile) = tempfile ($ps_template, UNLINK => 0, TMPDIR => 1);
 	syslog('info', "Print job comes from STDIN, writing incoming job to temp file $tempFile\n");
 
@@ -312,8 +313,11 @@ if ($conv_fail) {
 
 syslog('debug', "cups-x2go processed postscript file $psFile to $pdfFile");
 
-# after we have created the PDF from CUPS's PS file, we can drop the PS file
-unlink ($psFile);
+# After we have created the PDF from CUPS's PS file, we can drop the PS file.
+# If we read data from STDIN, though, let the END block handle this cleanup.
+if (!$need_ps_file_cleanup) {
+	unlink ($psFile);
+}
 
 my ($title_fh, $titleFile) = tempfile ($title_template, UNLINK => 1, TMPDIR => 1);
 print $title_fh $jobTitle;
@@ -332,8 +336,7 @@ for(my $i=0; $i<scalar(@sessions);$i++ )
 	}
 }
 
-unlink ($pdfFile);
-unlink ($titleFile);
+# Temporary file cleanup is hopefully handled correctly by File::Temp.
 
 END {
 	if ($need_ps_file_cleanup) {
diff --git a/debian/changelog b/debian/changelog
index 3f307fb..c756d05 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -23,6 +23,8 @@ cups-x2go (3.0.1.3-0x2go1) UNRELEASED; urgency=low
     - cups-x2go: unlink PS temporary file on-demand in END block. Also move
       closelog to END block, because we want to print diagnosis messages in
       the END block.
+    - cups-x2go: don't use unlink() explicitly. Trust File::Temp and our END
+      block to clean up correctly.
   * debian/control:
     - Add dependencies on perl-modules for core modules and ${perl:Depends}
       for perl itself.

--
Alioth's /srv/git/code.x2go.org/cups-x2go.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/cups-x2go.git


More information about the x2go-commits mailing list