From: Don Armstrong Date: Tue, 10 Apr 2018 23:13:18 +0000 (-0700) Subject: abstract out create_index_file in maintainer-indices X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=7a453bdf919ae80be0ee5ac4c5ea435ada122370;hp=4c6f1a650c353cb6b9dd576c729a493ae3286529;p=debbugs.git abstract out create_index_file in maintainer-indices --- diff --git a/scripts/maintainer-indices b/scripts/maintainer-indices index 2255aac..07b74b2 100755 --- a/scripts/maintainer-indices +++ b/scripts/maintainer-indices @@ -102,10 +102,8 @@ if (not lockpid($config{spool_dir}.'/lock/maintainer-indices')) { # tie new maint/source maint indexes for forward and reverse for my $idx (keys %{$indexes}) { for my $fr ('','_reverse') { - tie %{$indexes->{$idx}{"tie$fr"}}, - MLDBM => $indexes->{$idx}{"index$fr"}.'-new', - O_CREAT|O_TRUNC|O_RDWR, 0644 or - die qq(Unable to tie $indexes->{$idx}{"index$fr"}-new: $!); + $indexes->{$idx}{"tie$fr"} = + create_index_file($indexes->{$idx}{"index$fr"}.'-new'); } } for my $idx (keys %{$indexes}) { @@ -129,6 +127,16 @@ for my $idx (keys %{$indexes}) { } } +sub create_index_file { + my ($idx_fn) = @_; + my $idx = {}; + tie %{$idx}, + MLDBM => $idx_fn, + O_CREAT|O_TRUNC|O_RDWR, 0644 or + die qq(Unable to tie $idx_fn: $!); + return $idx; +} + sub add_to_index { my ($fn,$forward,$reverse,$type) = @_;