my $log = $self->_get_logger();
- $log->info("opening Koha database '$arg->{dsn}'");
+ if ( -e $arg->{path} ) {
+ $log->info("Koha marc dump ", $arg->{path}, " exists");
+ $self->{_koha_size} = 0;
+ } else {
- $self->{_dbh} = DBI->connect( $arg->{dsn}, $arg->{user}, $arg->{passwd}, { RaiseError => 1 } );
- $self->{_sth} = $self->{_dbh}->prepare( $arg->{sql} );
- $self->{_sth}->execute;
+ $log->info("opening Koha database '$arg->{dsn}'");
- warn "got ", $self->{_sth}->rows, " rows for ", $arg->{sql};
+ $self->{_dbh} = DBI->connect( $arg->{dsn}, $arg->{user}, $arg->{passwd}, { RaiseError => 1 } );
+ $self->{_sth} = $self->{_dbh}->prepare( $arg->{sql} );
+ $self->{_sth}->execute;
+ $self->{_koha_size} = $self->{_sth}->rows;
- open( $self->{_koha_fh}, '>', $arg->{path} ) || warn "not creating $arg->{path}: $!";
+ warn "got ", $self->{_koha_size}, " rows for ", $arg->{sql};
+
+ open( $self->{_koha_fh}, '>', $arg->{path} ) || die "can't create $arg->{path}: $!";
+
+ }
$self ? return $self : return undef;
}
sub size {
my $self = shift;
- return $self->{_sth}->rows;
+ return $self->{_koha_size};
}