From 63dfe6dd10da36fdbe7da88ed3754a0edab41591 Mon Sep 17 00:00:00 2001 From: doogie <> Date: Sun, 19 Aug 2001 01:09:18 -0800 Subject: [PATCH] [project @ 2001-08-19 02:09:18 by doogie] Add support for storing the files in a hashed directory(db-h), with the same hash layout as archive/. --- scripts/errorlib.in | 11 ++++++++--- scripts/expire.in | 43 ++++++++++++++++++------------------------- scripts/process.in | 37 +++++++++++++++++++++---------------- scripts/service.in | 27 ++++++++++++++------------- scripts/summary.in | 17 ++++++++++------- 5 files changed, 71 insertions(+), 64 deletions(-) diff --git a/scripts/errorlib.in b/scripts/errorlib.in index 338b7c17..c7c1f113 100755 --- a/scripts/errorlib.in +++ b/scripts/errorlib.in @@ -1,9 +1,14 @@ # -*- perl -*- -# $Id: errorlib.in,v 1.4 2001/07/15 09:46:16 doogie Exp $ +# $Id: errorlib.in,v 1.5 2001/08/19 02:09:18 doogie Exp $ sub F_SETLK { 6; } sub F_WRLCK{ 1; } $flockstruct= 'sslll'; # And there ought to be something for this too. +sub get_hashname { + return "" if ( $_[ 0 ] < 0 ); + return sprintf "%02d", $_[ 0 ] % 100; +} + sub unlockreadbugmerge { local ($rv) = @_; &unfilelock if $rv >= 2; @@ -23,7 +28,7 @@ sub lockreadbugmerge { sub lockreadbug { local ($lref) = @_; &filelock("lock/$lref"); - if (!open(S,"db/$lref.status")) { &unfilelock; return 0; } + if (!open(S,"db-h/".get_hashname($lref)."/$lref.status")) { &unfilelock; return 0; } chop($s_originator= ); chop($s_date= ); chop($s_subject= ); @@ -109,7 +114,7 @@ sub appendfile { if (!open(AP,">>$file")) { print DEBUG "failed open log<\n"; print DEBUG "failed open log err $!<\n"; - &quit("opening db/$ref.log (li): $!"); + &quit("opening $file (appendfile): $!"); } print(AP @_) || &quit("writing $file (appendfile): $!"); close(AP) || &quit("closing $file (appendfile): $!"); diff --git a/scripts/expire.in b/scripts/expire.in index e851f94b..1429dc96 100755 --- a/scripts/expire.in +++ b/scripts/expire.in @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $Id: expire.in,v 1.7 2001/08/16 07:25:53 doogie Exp $ +# $Id: expire.in,v 1.8 2001/08/19 02:09:18 doogie Exp $ # Load modules and set envirnment use File::Copy; @@ -17,21 +17,15 @@ chdir("$gSpoolDir") || die "chdir spool: $!\n"; $debug = 0; defined($startdate= time) || &quit("failed to get time: $!"); -sub get_archivename -{ my $bugnum = shift; - my $archivename = ""; - -# while( $bugnum > 99 ) { $bugnum = int $bugnum/10; } - $bugnum = $bugnum % 100; - $archivename = sprintf "%02d", $bugnum; - return $archivename; -} - #get list of bugs (ie, status files) -opendir(DIR,"db") || &quit("opendir db: $!\n"); -@list= grep(m/^\d+\.status$/,readdir(DIR)); -grep(s/\.status$//,@list); -@list= sort { $a <=> $b } @list; +opendir(DIR,"db-h") || &quit("opendir db: $!\n"); +@dirs = sort { $a <=> $b } grep(s,^,db-h/,, grep(m/^\d+$/,readdir(DIR))); +close(DIR); +foreach my $dir (@dirs) { + opendir(DIR,$dir); + push @list, sort { $a <=> $b } grep(s/\.status$//,grep(m/^\d+\.status$/,readdir(DIR))); + close(DIR); +} #process each bug (ie, status file) while (length($ref=shift(@list))) @@ -61,7 +55,7 @@ while (length($ref=shift(@list))) print "$ref $mref merge-ok\n" if $debug; length($s_done) || die "$ref -> $mref"; print "$ref $mref done-ok\n" if $debug; - $days= -M "db/$mref.log"; + $days= -M "db-h/".get_hashname($mref)."/$mref.log"; print "ref $mref days $days\n" if $debug; if ($days <= $gRemoveAge) { print "$ref $mref saved\n" if $debug; $oktoremove= 0;} @@ -70,22 +64,21 @@ while (length($ref=shift(@list))) { print "$ref removing\n" if $debug; for $mref (@aref) { print "$ref removing $mref\n" if $debug; + my $dir = get_hashname($mref); if ( $gSaveOldBugs ) { - my $dir; - $dir = "archive/" . get_archivename $mref; - `mkdir -p "$dir"`; - copy( "db/$mref.log", "$dir/$mref.log" ); - copy( "db/$mref.status", "$dir/$mref.status" ); - copy( "db/$mref.report", "$dir/$mref.report" ); - if ( open( IDXFILE, ">>archive/index" ) ) + `mkdir -p "archive2/$dir"`; + copy( "db-h/$dir/$mref.log", "archive2/$dir/$mref.log" ); + copy( "db-h/$dir/$mref.status", "archive2/$dir/$mref.status" ); + copy( "db-h/$dir/$mref.report", "archive2/$dir/$mref.report" ); + if ( open( IDXFILE, ">>archive2/index" ) ) { printf IDXFILE "%s %d %s\n", $s_package, $mref, $s_subject; close IDXFILE; } else { print "Unable to write to index file\n"; } - print("archived $mref to $dir (from $ref)\n") || &quit("output old: $!"); + print("archived $mref to archive2/$dir (from $ref)\n") || &quit("output old: $!"); } - unlink("db/$mref.log", "db/$mref.status", "db/$mref.report"); + unlink("db-h/$dir/$mref.log", "db-h/$dir/$mref.status", "db-h/$dir/$mref.report"); print("deleted $mref (from $ref)\n") || &quit("output old: $!"); } } diff --git a/scripts/process.in b/scripts/process.in index 811189b7..338aae48 100755 --- a/scripts/process.in +++ b/scripts/process.in @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $Id: process.in,v 1.35 2001/08/16 07:11:04 doogie Exp $ +# $Id: process.in,v 1.36 2001/08/19 02:09:18 doogie Exp $ # # Usage: process nn # Temps: incoming/Pnn @@ -267,13 +267,14 @@ END } $s_done= $set_done if defined($set_done); $s_forwarded= $set_forwarded if defined($set_forwarded); - &overwrite("db/$ref.status", + my $hash = get_hashname($ref); + &overwrite("db-h/$hash/$ref.status", "$s_originator\n$s_date\n$s_subject\n$s_msgid\n". "$s_package\n$s_keywords\n$s_done\n$s_forwarded\n$s_mergedwith\n$s_severity\n"); &bughook('change',$ref, "$s_originator\n$s_date\n$s_subject\n$s_msgid\n". "$s_package\n$s_keywords\n$s_done\n$s_forwarded\n$s_mergedwith\n$s_severity\n"); - open(O,"db/$ref.report") || &quit("read original report: $!"); + open(O,"db-h/$hash/$ref.report") || &quit("read original report: $!"); $x= join('',); close(O); if ($codeletter eq 'F') { &htmllog("Reply","sent",$replyto,"You have marked $gBug as forwarded."); @@ -481,14 +482,15 @@ END $ref= $v+0; $v += 1; $newref=1; &overwrite('nextnumber', "$v\n"); &unfilelock; - &overwrite("db/$ref.log",''); - &overwrite("db/$ref.status", + my $hash = get_hashname($ref); + &overwrite("db-h/$hash/$ref.log",''); + &overwrite("db-h/$hash/$ref.status", "$replyto\n$intdate\n$subject\n$header{'message-id'}\n". "$s_package\n$s_keywords\n\n\n\n$s_severity\n"); &bughook('new',$ref, "$replyto\n$intdate\n$subject\n$header{'message-id'}\n". "$s_package\n$s_keywords\n\n\n\n$s_severity\n"); - &overwrite("db/$ref.report", + &overwrite("db-h/$hash/$ref.report", join("\n",@msg)."\n"); } @@ -768,13 +770,14 @@ sub overwrite { } sub appendlog { - if (!open(AP,">>db/$ref.log")) { + my $hash = get_hashname($ref); + if (!open(AP,">>db-h/$hash/$ref.log")) { print DEBUG "failed open log<\n"; print DEBUG "failed open log err $!<\n"; - &quit("opening db/$ref.log (li): $!"); + &quit("opening db-h/$hash/$ref.log (li): $!"); } - print(AP "\7\n",@log,"\n\3\n") || &quit("writing db/$ref.log (li): $!"); - close(AP) || &quit("closing db/$ref.log (li): $!"); + print(AP "\7\n",@log,"\n\3\n") || &quit("writing db-h/$hash/$ref.log (li): $!"); + close(AP) || &quit("closing db-h/$hash/$ref.log (li): $!"); } sub finish { @@ -791,13 +794,14 @@ sub chldhandle { $chldexit = 'yes'; } sub htmllog { local ($whatobj,$whatverb,$where,$desc) = @_; - open(AP,">>db/$ref.log") || &quit("opening db/$ref.log (lh): $!"); + my $hash = get_hashname($ref); + open(AP,">>db-h/$hash/$ref.log") || &quit("opening db-h/$hash/$ref.log (lh): $!"); print(AP "\6\n". "$whatobj $whatverb to ".&sani($where). ":
\n". $desc. - "\n\3\n") || &quit("writing db/$ref.log (lh): $!"); - close(AP) || &quit("closing db/$ref.log (lh): $!"); + "\n\3\n") || &quit("writing db-h/$hash/$ref.log (lh): $!"); + close(AP) || &quit("closing db-h/$hash/$ref.log (lh): $!"); } sub get_addresses { @@ -811,11 +815,12 @@ sub sendmessage { local ($msg,@recips) = @_; if ($recips[0] eq '' && $#recips == 0) { @recips= ('-t'); } + my $hash = get_hashname($ref); #save email to the log - open(AP,">>db/$ref.log") || &quit("opening db/$ref.log (lo): $!"); + open(AP,">>db-h/$hash/$ref.log") || &quit("opening db-h/$hash/$ref.log (lo): $!"); print(AP "\2\n",join("\4",@recips),"\n\5\n$msg\n\3\n") || - &quit("writing db/$ref.log (lo): $!"); - close(AP) || &quit("closing db/$ref.log (lo): $!"); + &quit("writing db-h/$hash/$ref.log (lo): $!"); + close(AP) || &quit("closing db-h/$hash/$ref.log (lo): $!"); #if debbuging.. save email to a log # open AP, ">>debug"; diff --git a/scripts/service.in b/scripts/service.in index cb20d254..d9c86633 100755 --- a/scripts/service.in +++ b/scripts/service.in @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $Id: service.in,v 1.41 2001/08/16 07:24:18 doogie Exp $ +# $Id: service.in,v 1.42 2001/08/19 02:09:18 doogie Exp $ # ^ more or less ^ # # Usage: service .nn @@ -580,7 +580,7 @@ END $repliedshow= join(', ',$replyto,@maintccaddrs); &filelock("lock/-1"); -open(AP,">>db/-1.log") || &quit("open db/-1.log: $!"); +open(AP,">>db-h/-1.log") || &quit("open db-h/-1.log: $!"); print(AP "\2\n$repliedshow\n\5\n$reply\n\3\n". "\6\n". @@ -588,10 +588,10 @@ print(AP &sani($header{'from'})."\n". "to ".&sani($controlrequestaddr)."\n". "\3\n". - "\7\n",@log,"\n\3\n") || &quit("writing db/-1.log: $!"); -close(AP) || &quit("open db/-1.log: $!"); + "\7\n",@log,"\n\3\n") || &quit("writing db-h/-1.log: $!"); +close(AP) || &quit("open db-h/-1.log: $!"); &unfilelock; -utime(time,time,"db"); +utime(time,time,"db-h"); &sendmailmessage($reply,$replyto,@maintccaddrs); @@ -787,16 +787,17 @@ sub savebug { $lowstate eq 'open' || die "$lowstate ?"; length($action) || die; $ref == $sref || die "read $sref but saving $ref ?"; - open(L,">>db/$ref.log") || &quit("opening db/$ref.log: $!"); + my $hash = get_hashname($ref); + open(L,">>db-h/$hash/$ref.log") || &quit("opening db-h/$hash/$ref.log: $!"); print(L "\6\n". "".&sani($action)."\n". "Request was from ".&sani($header{'from'})."\n". "to ".&sani($controlrequestaddr).". \n". "\3\n". - "\7\n",@log,"\n\3\n") || &quit("writing db/$ref.log: $!"); - close(L) || &quit("closing db/$ref.log: $!"); - open(S,">db/$ref.status.new") || &quit("opening db/$ref.status.new: $!"); + "\7\n",@log,"\n\3\n") || &quit("writing db-h/$hash/$ref.log: $!"); + close(L) || &quit("closing db-h/$hash/$ref.log: $!"); + open(S,">db-h/$hash/$ref.status.new") || &quit("opening db-h/$hash/$ref.status.new: $!"); print(S "$s_originator\n". "$s_date\n". @@ -807,10 +808,10 @@ sub savebug { "$s_done\n". "$s_forwarded\n". "$s_mergedwith\n". - "$s_severity\n") || &quit("writing db/$ref.status.new: $!"); - close(S) || &quit("closing db/$ref.status.new: $!"); - rename("db/$ref.status.new","db/$ref.status") || - &quit("installing new db/$ref.status: $!"); + "$s_severity\n") || &quit("writing db-h/$hash/$ref.status.new: $!"); + close(S) || &quit("closing db-h/$hash/$ref.status.new: $!"); + rename("db-h/$hash/$ref.status.new","db-h/$hash/$ref.status") || + &quit("installing new db-h/$hash/$ref.status: $!"); &bughook('change',$ref, "$s_originator\n". "$s_date\n". diff --git a/scripts/summary.in b/scripts/summary.in index a84ca793..bac741f3 100755 --- a/scripts/summary.in +++ b/scripts/summary.in @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $Id: summary.in,v 1.4 2001/08/16 17:37:01 doogie Exp $ +# $Id: summary.in,v 1.5 2001/08/19 02:09:18 doogie Exp $ $config_path = '/org/bugs.debian.org/etc'; $lib_path = '/org/bugs.debian.org/scripts'; @@ -34,10 +34,14 @@ close(M); defined($startdate= time) || &quit("failed to get time: $!"); -opendir(DIR,"db") || &quit("opendir db: $!\n"); -@list= grep(m/^\d+\.status$/,readdir(DIR)); -grep(s/\.status$//,@list); -@list= sort { $a <=> $b } @list; +opendir(DIR,"db-h") || &quit("opendir db: $!\n"); +@dirs = sort { $a <=> $b } grep(s,^,db-h/,, grep(m/^\d+$/,readdir(DIR))); +close(DIR); +foreach my $dir (@dirs) { + opendir(DIR,$dir); + push @list, sort { $a <=> $b } grep(s/\.status$//,grep(m/^\d+\.status$/,readdir(DIR))); + close(DIR); +} $head= $mode eq 'bymaint' ? ' Package Ref Subject' @@ -45,8 +49,7 @@ $head= $mode eq 'bymaint' $amonths=-1; while (length($f=shift(@list))) { - &filelock("lock/$f"); - if (!open(S,"db/$f.status")) { &unlinklock; next; } + if (!lockreadbug($f)) { next; } chop($s_originator= ); chop($s_date= ); chop($s_subject= ); -- 2.39.5