From: doogie <> Date: Sat, 29 Apr 2000 17:06:31 +0000 (-0800) Subject: [project @ 2000-04-29 10:06:31 by doogie] X-Git-Tag: release/2.6.0~1304 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=4ba5390afa418ddeb4235f9c7f048e5681d48a8f;p=debbugs.git [project @ 2000-04-29 10:06:31 by doogie] 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. :| --- diff --git a/Debbugs/Common.pm b/Debbugs/Common.pm index 243c324..9c8e96c 100644 --- a/Debbugs/Common.pm +++ b/Debbugs/Common.pm @@ -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) diff --git a/Debbugs/DBase.pm b/Debbugs/DBase.pm index 3bf5371..2a5fd0f 100644 --- a/Debbugs/DBase.pm +++ b/Debbugs/DBase.pm @@ -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" );