IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 15, 2009, 10:51:10 AM (17 years ago)
Author:
jhoblitt
Message:

update

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous-Server/scripts/dirize.pl

    r24250 r24404  
    11#!/usr/bin/env perl
     2
     3# query to check for duplicate directory entries
     4# select count(*) from (select so.so_id, so.ext_id, so.dir_id from storage_object as so join (select dir_id, dirname, parent_id, count(*) from directory group by dirname, parent_id  having count(*) > 1) as foo on so.dir_id = foo.dir_id) as foo;
    25
    36use strict;
     
    3033#}
    3134
    32 my $query = $db->prepare_cached("SELECT so_id, ext_id, dir_id FROM storage_object AS so WHERE so.dir_id = 0 LIMIT 1000");
     35# repair directory duplication
     36#my $query = $db->prepare_cached("select so.so_id, so.ext_id, so.dir_id from storage_object as so join (select dir_id, dirname, parent_id, count(*) from directory group by dirname, parent_id  having count(*) > 1) as foo on so.dir_id = foo.dir_id limit 1000");
     37
     38# initial directory fill in
     39my $query = $db->prepare_cached("SELECT so_id, ext_id, dir_id FROM storage_object AS so WHERE so.dir_id = 0 LIMIT 100000");
     40
     41$db->do("SET FOREIGN_KEY_CHECKS=0");
     42#$db->do("UPDATE storage_object SET dir_id = 0");
     43#$db->do("DELETE FROM directory");
    3344
    3445my $i = 0;
     
    4051
    4152#printf("dirizing %20s basename: %20s parent_id %10d\n", $key, basename($row->{'ext_id'}), $parent_id);
    42         printf("$i/$n dirizing %s\n", $key->path);
     53#        printf("$i dirizing %s\n", $key->path);
    4354
    4455        my $q = $db->prepare_cached("UPDATE storage_object SET ext_id_basename = ?, dir_id = ? WHERE so_id = ?");
    4556        $q->execute(basename($row->{'ext_id'}), $parent_id, $row->{'so_id'});
    46         $db->commit;
    4757    }
     58    $db->commit;
     59    printf("### COMMIT ###\n");
    4860    $query->finish;
     61    printf("dirized $i\n");
    4962}
     63
     64$db->do("SET FOREIGN_KEY_CHECKS=1");
     65
     66# remove unused dirs
     67#$db-do("");
     68#$db->commit;
Note: See TracChangeset for help on using the changeset viewer.