]> git.donarmstrong.com Git - debbugs.git/commitdiff
[project @ 2000-04-29 10:06:31 by doogie]
authordoogie <>
Sat, 29 Apr 2000 17:06:31 +0000 (09:06 -0800)
committerdoogie <>
Sat, 29 Apr 2000 17:06:31 +0000 (09:06 -0800)
Added a NameToPathHash, that implements the following algorithm, similiar to
what has been discussed during several dinstall discussions.

db/12345.status -> db/5/4/3/12345.status
db/12.status -> db/s/2/1/12.status

Still left to do is write a converter program to transform the layout.
I've tested that this works on master.  It has code to work with both the old
and new dir layout, so there should be no problem using this in current
setups.  That is, if DBase.pm was used in any of the perl scripts. :|

Debbugs/Common.pm
Debbugs/DBase.pm

index 243c3246d745c45aded697f6ee3008cb57035a56..9c8e96cecd4512a0ec43b9faf4a8d272a94c2301 100644 (file)
@@ -26,6 +26,20 @@ sub fail
        print "$_[0]\n";
        exit 1;
 }
+sub NameToPathHash
+{
+#   12345 -> 5/4/3/12345
+#   12 -> s/2/1/12
+    my $name = $_[0];
+    my $tmp = $name;
+    $name =~ /^.*?(.)(.)(.)$/ ;
+    if(!defined($1)) {
+       $name =~ /^(.*?)(.)(.)$/ ;
+       $tmp = "$1$2$3"."s";
+    }
+    $tmp =~ /^.*?(.)(.)(.)$/ ;
+    return "$3/$2/$1/$name";
+}
 
 1;
 END { }       # module clean-up code here (global destructor)
index 3bf53716d0b1436a9ed8257b27ae87dfc928bd48..2a5fd0fd9bee848dab24f637fa9870b1f3c7fd30 100644 (file)
@@ -74,14 +74,14 @@ sub ReadRecord
        my $path = '';
        my @data;
 
-        print "D1: (DBase) $record is being loaded\n" if $Globals{ 'debug' }; 
-       
-       #find proper directory to store in
-        #later, this will be for tree'd data directory the way
-        #expire is now,..
+       print "D1: (DBase) $record is being loaded\n" if $Globals{ 'debug' };
+
        $path = "/db/".$record.".status";
+       if( ! -r $Globals{ "work-dir" } . $path ) {
+           $path = "/db/".&NameToPathHash($record).".status";
+       }
        print "D2: (DBase) $path found as data path\n" if $Globals{ 'debug' } > 1;
-    
+       
        open( $FileHandle, $Globals{ "work-dir" } . $path ) 
            || &fail( "Unable to open record: ".$Globals{ "work-dir" }."$path\n");
        flock( $FileHandle, LOCK_EX ) || &fail( "Unable to lock record $record\n" );