From 7a453bdf919ae80be0ee5ac4c5ea435ada122370 Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Tue, 10 Apr 2018 16:13:18 -0700 Subject: [PATCH 1/1] abstract out create_index_file in maintainer-indices --- scripts/maintainer-indices | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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) = @_; -- 2.39.2