projects
/
freeside.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b731fd6
)
roll back the import transaction on fatal parsing errors on CDR import, so the cdr_ba...
author
ivan
<ivan>
Wed, 25 Aug 2010 09:25:56 +0000
(09:25 +0000)
committer
ivan
<ivan>
Wed, 25 Aug 2010 09:25:56 +0000
(09:25 +0000)
FS/FS/Record.pm
patch
|
blob
|
history
diff --git
a/FS/FS/Record.pm
b/FS/FS/Record.pm
index
71cc69c
..
6b05d2d
100644
(file)
--- a/
FS/FS/Record.pm
+++ b/
FS/FS/Record.pm
@@
-1871,7
+1871,13
@@
sub batch_import {
while ( scalar(@later) ) {
my $sub = shift @later;
my $data = shift @later;
while ( scalar(@later) ) {
my $sub = shift @later;
my $data = shift @later;
- &{$sub}($record, $data, $conf, $param); # $record->&{$sub}($data, $conf);
+ eval {
+ &{$sub}($record, $data, $conf, $param); # $record->&{$sub}($data, $conf)
+ };
+ if ( $@ ) {
+ $dbh->rollback if $oldAutoCommit;
+ return "can't insert record". ( $line ? " for $line" : '' ). ": $@";
+ }
last if exists( $param->{skiprow} );
}
next if exists( $param->{skiprow} );
last if exists( $param->{skiprow} );
}
next if exists( $param->{skiprow} );
@@
-1902,9
+1908,12
@@
sub batch_import {
}
}
- $dbh->commit or die $dbh->errstr if $oldAutoCommit;;
+ unless ( $imported || $param->{empty_ok} ) {
+ $dbh->rollback if $oldAutoCommit;
+ return "Empty file!";
+ }
-
return "Empty file!" unless $imported || $param->{empty_ok}
;
+
$dbh->commit or die $dbh->errstr if $oldAutoCommit;
;
''; #no error
''; #no error