fix -g gunzipping, RT#10991
[freeside.git] / FS / bin / freeside-cdr-sftp_and_import
index e09f7dc..1d052ea 100755 (executable)
@@ -95,8 +95,14 @@ foreach my $filename ( @$ls ) {
   warn "Processing $filename\n" if $opt_v;
  
   my $ungziped = $filename;
-  my $ungziped =~ s/\.gz$//;
-  system("gunzip $cachedir/$filename") if $opt_g;
+  $ungziped =~ s/\.gz$//;
+  if ( $opt_g ) {
+      if(system('gunzip', "$cachedir/$filename") != 0) {
+        warn "gunzip of '$cachedir/$filename' failed" if $opt_v;
+        unlink "$cachedir/$filename";
+        next;
+      }
+  }
 
   my $import_options = {
     'file'            => "$cachedir/$ungziped",