fix parsing of gzip -l output
[BackupPC.git] / bin / BackupPC_ASA_PostArchive_Update
index 33527a0..11de07e 100755 (executable)
@@ -66,7 +66,7 @@ my $start_t = time();
 
 my $t_fmt = '%Y-%m-%d %H:%M:%S';
 
-warn "## Conf = ",dump( \%Conf );
+#warn "## Conf = ",dump( \%Conf );
 
 my $dbh = DBI->connect($Conf{SearchDSN}, $Conf{SearchUser}, "", { RaiseError => 1, AutoCommit => 0 });
 
@@ -176,20 +176,21 @@ sub check_archive {
                }
 
                open(my $gzip, $Conf{GzipPath}." -l $filename |") || die "can't gzip -l $filename: $!";
+               local $/ = undef;
                my $line = <$gzip>;
-               chomp($line);
-               $line = <$gzip> if ($line =~ /^\s+compressed/);
+               close($gzip);
 
                my ($comp, $uncomp) = (0,0);
 
-               if ($line =~ m/^\s+(\d+)\s+(\d+)\s+\d+\.\d+/) {
+               if ($line =~ m/\s+(\d+)\s+(\d+)\s+\d+\.\d+/s) {
                        if (wantarray) {
                                return [ $1, $2 ];
                        } else {
                                return $2;
                        }
                } else {
-                       die "can't find size in line: $line";
+                       warn "ERROR can't parse: $line";
+                       return -s $filename;
                }
        }