- } else {
- eval {
- require Storable;
- };
-
- if ($@) {
- if ( ! -e localdata("users.v3") && -e localdata("users.v2") ) {
- $convert = 2;
- }
- LogDbg('',"the module Storable appears to be missing!!");
- LogDbg('',"trying to continue in compatibility mode (this may fail)");
- LogDbg('',"please install Storable from CPAN as soon as possible");
- } else {
- import Storable qw(nfreeze thaw);
- $convert = 3 if -e localdata("users.v3") && !-e $ufn;
- }
- }
-
- # do a conversion if required
- if ($convert) {
- my ($key, $val, $action, $count, $err) = ('','',0,0,0);
- my $ta = [gettimeofday];
-
- my %oldu;
- LogDbg('',"Converting the User File from V$convert to $fn.v4 ");
- LogDbg('',"This will take a while, I suggest you go and have cup of strong tea");
- my $odbm = tie (%oldu, 'DB_File', localdata("users.v$convert"), O_RDONLY, 0666, $DB_BTREE) or confess "can't open user file: $fn.v$convert ($!) [rebuild it from user_asc?]";
- for ($action = R_FIRST; !$odbm->seq($key, $val, $action); $action = R_NEXT) {
- my $ref;
- if ($convert == 3) {
- eval { $ref = storable_decode($val) };
- } else {
- eval { $ref = asc_decode($val) };
- }
- unless ($@) {
- if ($ref) {
- $u{$key} = $ref;
- $count++;
- } else {
- $err++
- }
- } else {
- Log('err', "DXUser: error decoding $@");
- }
- }
- undef $odbm;
- untie %oldu;
- my $t = _diffms($ta);
- LogDbg('',"Conversion from users.v$convert to users.v4 completed $count records $err errors $t mS");
-
- # now write it away for future use
- $ta = [gettimeofday];
- $err = 0;
- $count = writeoutjson();
- $t = _diffms($ta);
- LogDbg('',"New Userfile users.v4 write completed $count records $err errors $t mS");
- LogDbg('',"Now restarting..");
- $main::ending = 10;
- } else {
- # otherwise (i.e normally) slurp it in