summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2012-11-15 13:50:11 -0800
committerMark Wells <mark@freeside.biz>2012-11-15 13:50:30 -0800
commitc673787bf1ac56408e589ed20ea63404e9181574 (patch)
tree5c06d5a5239665c586c007efded20cb34b97ee94 /FS
parent2bb7db96a07599e980323c1b6b23a8c79cc17a9a (diff)
better error handling when sending a spool by email, #17620
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/Cron/upload.pm23
-rw-r--r--FS/FS/Misc.pm1
-rw-r--r--FS/FS/upload_target.pm7
3 files changed, 20 insertions, 11 deletions
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