[Debpool-commits] [SCM] Debpool Project Repository branch, master, updated. debian/0.3.6-8-g8ceb95c

Andres Mejia mcitadel at gmail.com
Thu Oct 16 22:56:00 UTC 2008


The following commit has been merged in the master branch:
commit 8ceb95ce32f9791bacd3fccb8bc6138786451b12
Author: Andres Mejia <mcitadel at gmail.com>
Date:   Thu Oct 16 18:55:54 2008 -0400

    Fixing basic perlcritic messages from new compression modules.

diff --git a/lib/DebPool/Bzip2.pm b/lib/DebPool/Bzip2.pm
index 4b47803..36b7953 100644
--- a/lib/DebPool/Bzip2.pm
+++ b/lib/DebPool/Bzip2.pm
@@ -91,7 +91,7 @@ our($Error);
 # Bzip_File($file)
 #
 # Generates a bzipped version of $file, and returns the filename. Returns
-# undef (and sets $Error) on failure.
+# 0 (and sets $Error) on failure.
 
 sub Bzip2_File {
     use DebPool::Logging qw(:functions :facility :level);
@@ -105,28 +105,29 @@ sub Bzip2_File {
     my $bz = bzopen($tmpfile, 'wb9');
     if (!$bz) {
         $Error = "Couldn't initialize compression library: " . $bzerrno;
-        return undef;
+        return 0;
     }
 
     # Open the source file so that we have it available.
-    if (!open(SOURCE, '<', $file)) {
+    my $source;
+    if (!open($source, '<', $file)) {
         $Error = "Couldn't open source file '$file': $!";
-        return undef;
+        return 0;
     }
 
     while (1) {
         my $buffer;
-        my $bytesread = read SOURCE, $buffer, 4096;
+        my $bytesread = read $source, $buffer, 4096;
         if (!defined $bytesread) {
             $Error = "Error reading from '$file': $!";
-            close SOURCE;
-            return undef;
+            close $source;
+            return 0;
         }
         my $byteswritten = $bz->bzwrite($buffer);
         if ($byteswritten < $bytesread) {
             $Error = "Error bzwriting to temporary file: " . $bz->bzerror;
-            close SOURCE;
-            return undef;
+            close $source;
+            return 0;
         }
         last if $bytesread == 0;
     }
@@ -136,19 +137,22 @@ sub Bzip2_File {
     # BZ_OK and BZ_STREAM_END are ok
     if (($bzflush != BZ_OK) && ($bzflush != BZ_STREAM_END)) {
         $Error = "Error flushing compressed file: " . $bz->bzerror;
-        close SOURCE;
-        return undef;
+        close $source;
+        return 0;
     }
 
     # And we're done
-    close SOURCE;
+    close $source;
     $bz->bzclose;
     $tmpfile->unlink_on_destroy(0);
     return $tmpfile->filename;
 }
 
 sub new {
-    bless { ERROR => undef };
+    my $class = shift;
+    my $self = { 'ERROR' => undef };
+    bless $self, $class;
+    return $self;
 }
 
 sub Compress_File {
diff --git a/lib/DebPool/Gzip.pm b/lib/DebPool/Gzip.pm
index aee1a6f..ebf8608 100644
--- a/lib/DebPool/Gzip.pm
+++ b/lib/DebPool/Gzip.pm
@@ -91,7 +91,7 @@ our($Error);
 # Gzip_File($file)
 #
 # Generates a gzipped version of $file using Compress::Zlib, and returns the
-# filename. Returns undef (and sets $Error) on failure.
+# filename. Returns 0 (and sets $Error) on failure.
 
 sub Gzip_File {
     use DebPool::Logging qw(:functions :facility :level);
@@ -105,28 +105,29 @@ sub Gzip_File {
     my $gz = gzopen($tmpfile, 'wb9');
     if (!$gz) {
         $Error = "Couldn't initialize compression library: $gzerrno";
-        return undef;
+        return 0;
     }
 
     # Open the source file so that we have it available.
-    if (!open(SOURCE, '<', $file)) {
+    my $source;
+    if (!open($source, '<', $file)) {
         $Error = "Couldn't open source file '$file': $!";
-        return undef;
+        return 0;
     }
 
     while (1) {
         my $buffer;
-        my $bytesread = read SOURCE, $buffer, 4096;
+        my $bytesread = read $source, $buffer, 4096;
         if (!defined $bytesread) {
             $Error = "Error reading from '$file': $!";
-            close SOURCE;
-            return undef;
+            close $source;
+            return 0;
         }
         my $byteswritten = $gz->gzwrite($buffer);
         if ($byteswritten < $bytesread) {
             $Error = "Error gzwriting to temporary file: " . $gz->gzerror;
-            close SOURCE;
-            return undef;
+            close $source;
+            return 0;
         }
         last if $bytesread == 0;
     }
@@ -137,19 +138,22 @@ sub Gzip_File {
     if (($gzflush != Z_OK) && ($gzflush != Z_STREAM_END)) {
         $Error = "Error flushing compressed file: " . $gz->gzerror;
         print "$Error\n";
-        close SOURCE;
-        return undef;
+        close $source;
+        return 0;
     }
 
     # And we're done
-    close SOURCE;
+    close $source;
     $gz->gzclose;
     $tmpfile->unlink_on_destroy(0);
     return $tmpfile->filename;
 }
 
 sub new {
-    bless { ERROR => undef };
+    my $class = shift;
+    my $self = { 'ERROR' => undef };
+    bless $self, $class;
+    return $self;
 }
 
 sub Compress_File {

-- 
Debpool Project Repository



More information about the Debpool-commits mailing list