Changeset 24404 for trunk/Nebulous-Server/scripts/dirize.pl
- Timestamp:
- Jun 15, 2009, 10:51:10 AM (17 years ago)
- File:
-
- 1 edited
-
trunk/Nebulous-Server/scripts/dirize.pl (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous-Server/scripts/dirize.pl
r24250 r24404 1 1 #!/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; 2 5 3 6 use strict; … … 30 33 #} 31 34 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 39 my $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"); 33 44 34 45 my $i = 0; … … 40 51 41 52 #printf("dirizing %20s basename: %20s parent_id %10d\n", $key, basename($row->{'ext_id'}), $parent_id); 42 printf("$i/$ndirizing %s\n", $key->path);53 # printf("$i dirizing %s\n", $key->path); 43 54 44 55 my $q = $db->prepare_cached("UPDATE storage_object SET ext_id_basename = ?, dir_id = ? WHERE so_id = ?"); 45 56 $q->execute(basename($row->{'ext_id'}), $parent_id, $row->{'so_id'}); 46 $db->commit;47 57 } 58 $db->commit; 59 printf("### COMMIT ###\n"); 48 60 $query->finish; 61 printf("dirized $i\n"); 49 62 } 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.
