diff options
author | Mark Wells <mark@freeside.biz> | 2012-11-15 13:50:11 -0800 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2012-11-15 13:50:30 -0800 |
commit | c673787bf1ac56408e589ed20ea63404e9181574 (patch) | |
tree | 5c06d5a5239665c586c007efded20cb34b97ee94 /FS/FS/Cron | |
parent | 2bb7db96a07599e980323c1b6b23a8c79cc17a9a (diff) |
better error handling when sending a spool by email, #17620
Diffstat (limited to 'FS/FS/Cron')
-rw-r--r-- | FS/FS/Cron/upload.pm | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/FS/FS/Cron/upload.pm b/FS/FS/Cron/upload.pm index a9094c0b0..08819fce9 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; + } } |