[freeside-commits] branch master updated. c673787bf1ac56408e589ed20ea63404e9181574

Mark Wells mark at 420.am
Thu Nov 15 13:51:03 PST 2012


The branch, master has been updated
       via  c673787bf1ac56408e589ed20ea63404e9181574 (commit)
      from  2bb7db96a07599e980323c1b6b23a8c79cc17a9a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit c673787bf1ac56408e589ed20ea63404e9181574
Author: Mark Wells <mark at freeside.biz>
Date:   Thu Nov 15 13:50:11 2012 -0800

    better error handling when sending a spool by email, #17620

diff --git a/FS/FS/Cron/upload.pm b/FS/FS/Cron/upload.pm
index a9094c0..08819fc 100644
--- a/FS/FS/Cron/upload.pm
+++ b/FS/FS/Cron/upload.pm
@@ -318,7 +318,13 @@ sub spool_upload {
       system($command) and die "$command failed\n";
 
       my $error = $upload_target->put($zipfile);
-      die $error if $error;
+      if ( $error ) {
+        foreach ( qw ( header detail ) ) {
+          rename "$dir/$file-$date-$_.csv",
+                 "$dir/$file-$_.csv";
+          die $error;
+        }
+      }
 
       send_report('bridgestone-confirm_template',
         {
@@ -373,7 +379,7 @@ sub spool_upload {
       my $zipfile = "$basename" . '.zip';
       my $command = "cd $dir; zip $zipfile $regfile $bigfile";
       system($command) and die "'$command' failed\n";
-      $upload_target->put("$dir/$zipfile");
+      my $error = $upload_target->put("$dir/$zipfile");
 
       for (values %sum) {
         $_ = sprintf('%.2f', $_);
@@ -384,15 +390,24 @@ sub spool_upload {
           agentnum  => $agentnum,
           count     => \%count,
           sum       => \%sum,
+          error     => $error,
         }
       );
+
+      if ( $error ) {
+        rename "$dir/$file-$date.csv", "$dir/$file.csv";
+        die $error;
+      }
  
-      } else { # not bridgestone or ics
+    } else { # not bridgestone or ics
 
       # this is the usual case
 
       my $error = $upload_target->put("$file-$date.csv");
-      die $error if $error;
+      if ( $error ) {
+        rename "$dir/$file-$date.csv", "$dir/$file.csv";
+        die $error;
+      }
 
     }
 
diff --git a/FS/FS/Misc.pm b/FS/FS/Misc.pm
index a1c15fd..096ec8a 100644
--- a/FS/FS/Misc.pm
+++ b/FS/FS/Misc.pm
@@ -274,6 +274,7 @@ sub send_email {
     });
     $cust_msg->insert; # ignore errors
   }
+  $error;
    
 }
 
diff --git a/FS/FS/upload_target.pm b/FS/FS/upload_target.pm
index 8466a62..f3486d3 100644
--- a/FS/FS/upload_target.pm
+++ b/FS/FS/upload_target.pm
@@ -182,13 +182,6 @@ sub put {
   }
 }
 
-
-
-
-
-
-
-
 =item connect
 
 Creates a Net::FTP or Net::SFTP::Foreign object (according to the setting

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Cron/upload.pm   |   23 +++++++++++++++++++----
 FS/FS/Misc.pm          |    1 +
 FS/FS/upload_target.pm |    7 -------
 3 files changed, 20 insertions(+), 11 deletions(-)




More information about the freeside-commits mailing list