From: Frank Lichtenheld Date: Thu, 18 Jun 2009 19:27:58 +0000 (+0200) Subject: create_index_pages: Do not die due to namespace collisions X-Git-Url: https://git.deb.at/w?a=commitdiff_plain;h=41ebce59dc918cf53ec606ec288ff99b8d7e5520;p=deb%2Fpackages.git create_index_pages: Do not die due to namespace collisions If for whatever reason the same name appears in more than one set of sections, subsections, and priorities, the code used to die. The new code will not handle this very well either (you will get repeated lines in the affected file), but at least it will not take everything else with it. --- diff --git a/bin/create_index_pages b/bin/create_index_pages index 3e9fc52..66d7838 100755 --- a/bin/create_index_pages +++ b/bin/create_index_pages @@ -10,6 +10,7 @@ use Storable; use HTML::Entities; use URI::Escape; use Compress::Zlib; +use IO::Handle; use lib './lib'; @@ -75,6 +76,10 @@ sub open_file { print "opening $key\n"; mkdirp ( "$wwwdir/$key" ); + if ($fh{$key}) { + warn "filehandle for $key already open\n"; + return; + } open($fh{$key}, '>', "$wwwdir/$key/$file.slices.new") or die "Cannot open file $wwwdir/$key/$file.slices.new: $!"; @@ -95,6 +100,10 @@ sub close_file { $file ||= 'index'; print "closing $key\n"; + unless ($fh{$key}->opened()) { + warn "filehandle for $key already closed\n"; + return; + } foreach my $lang (@LANGUAGES) { print {$fh{$key}} "\n$s{begin}{$lang}\n";