2 # Migrate an old-style database to the new hashed (db-h) form.
9 Usage: $0 old-db-directory new-db-directory
11 debbugs-dbhash converts an old-style flat debbugs database into a
12 new-style hashed-directory debbugs database.
14 The old database is simply copied, and otherwise left untouched.
15 The directory given for the new database must not already exist.
21 my ($db, $dbh) = @ARGV[0, 1];
22 opendir DB, $db or die "Can't opendir $db: $!";
23 mkdir $dbh or die "Can't mkdir $dbh: $!";
25 my $dir = sprintf '%s/%02d', $dbh, $i;
26 mkdir $dir or die "Can't mkdir $dir: $!";
29 while (defined(my $file = readdir DB)) {
30 next if $file =~ /^\.\.?$/;
31 my $oldfile = "$db/$file";
33 if ($file =~ /(\d*)(\d\d)\.(.*)/) {
34 $newfile = "$dbh/$2/$1$2.$3";
36 warn "Not hashing $file.\n";
37 $newfile = "$dbh/$file";
39 copy $oldfile, $newfile or warn "Can't copy $oldfile to $newfile: $!";