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. :|
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)
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" );