+
+ if ($dbh && $v4 && $convert) {
+ my ($key, $val, $action, $count, $err) = ('','',0,0,0);
+
+ # create the table
+ my $table = q{create table user(
+call text not null unique,
+lastseen int not null,
+data text not null
+)};
+ $dbh->do($table) or die "cannot create user table in $ufn " . $dbh->errstr;
+
+ # Add indexes
+ $dbh->do(q(create index x1 on user(lastseen))) or die $dbh->errstr;
+
+ my %oldu;
+ dbg("Converting the User File to V4 ");
+ dbg("This will take a while, I suggest you go and have cup of strong tea");
+ require DB_File;
+ require Storable;
+ import DB_File;
+ import Storable qw(nfreeze thaw);
+ my $odbm = tie (%oldu, 'DB_File', "$fn.v3", O_RDONLY, 0666, $DB_File::DB_BTREE) or confess "can't open user file: $fn.v3 ($!) [rebuild it from user_asc?]";
+ $dbh->begin_work;
+ for ($action = DB_File::R_FIRST; !$odbm->seq($key, $val, $action); $action = DB_File::R_NEXT) {
+ my $ref = thaw($val);
+ if ($ref) {
+ my $r = _insert($ref);
+ if ($r) {
+ $count++;
+ } else {
+ $err++;
+ dbg("error converting call $ref->{call} - " . $dbh->errstr);
+ }
+ } else {
+ $err++
+ }
+ }
+ $dbh->commit;
+ undef $odbm;
+ untie %oldu;
+ dbg("Conversion completed $count records $err errors");
+
+ }
+
+ $lru = LRU->newbase("DXUser", $lrusize);
+