fix export_users cmd
authorDirk Koopman <djk@tobit.co.uk>
Sun, 26 Apr 2020 12:31:50 +0000 (13:31 +0100)
committerDirk Koopman <djk@tobit.co.uk>
Sun, 26 Apr 2020 12:31:50 +0000 (13:31 +0100)
Actually make sure that DXUser::del_file removes all versions
of users.v3 it can find whether in /spider/data and in /spider/local_data.

In the process make sure that the DEFAULT place that "localdata(<file>)
places that <file> is in /spider/local_data.

perl/DXUser.pm
perl/DXUtil.pm

index 6a06bb3c32baa4278543b32c2764cc8305e264f6..26eb3d424000528561df17944f0c13b04e9acaf1 100644 (file)
@@ -177,9 +177,9 @@ sub init
 
 sub del_file
 {
-       my $fn = localdata("users");
-       $fn .= $v3 ? ".v3" : ".v2";
-       unlink $fn;
+       # with extreme prejudice
+       unlink "$main::data/users.v3";
+       unlink "$main::local_data/users.v3";
 }
 
 #
@@ -488,12 +488,13 @@ while (<DATA>) {
        if ($ref) {
                $ref->put();
                $count++;
+        DXUser::sync() unless $count % 10000;
        } else {
                print "# Error: $f[0]\t$f[1]\n";
                $err++
        }
 }
-DXUser::sync; DXUser::finish;
+DXUser::sync(); DXUser::finish();
 print "There are $count user records and $err errors\n";
 };
                print $fh "__DATA__\n";
index 28e7396dcebd3143d25d29b49c989e98c4c7592d..4477a94bef90a3ef8e5abdc5ad5814fc53eb3bbb 100644 (file)
@@ -472,16 +472,14 @@ sub deleteitem
 sub localdata
 {
        my $ifn = shift;
-       my $ofn = "$main::data/$ifn";
+       my $ofn = "$main::local_data/$ifn";
        my $tfn;
        
        if (-e "$main::local_data") {
-               $tfn = "$main::local_data/$ifn";
+               $tfn = "$main::data/$ifn";
                if (-e $tfn && -e $ofn) {
-                       $ofn = $tfn if -M $tfn < -M $ofn;
-               } elsif (-e $tfn) {
-                       $ofn = $tfn;
-               }
+                       $ofn = $tfn if -M $ofn < -M $tfn;
+               } 
        }
 
        return $ofn;