From 4ba5390afa418ddeb4235f9c7f048e5681d48a8f Mon Sep 17 00:00:00 2001 From: doogie <> Date: Sat, 29 Apr 2000 09:06:31 -0800 Subject: [PATCH] [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. :| --- Debbugs/Common.pm | 14 ++++++++++++++ Debbugs/DBase.pm | 12 ++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Debbugs/Common.pm b/Debbugs/Common.pm index 243c3246..9c8e96ce 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 3bf53716..2a5fd0fd 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" ); -- 2.39.5