read_recap: Delete from %config any status values missing from recap

This commit is contained in:
Richard Hansen 2024-08-22 03:19:45 -04:00
parent c9cdb96086
commit 989f8be8c3
2 changed files with 7 additions and 2 deletions

View file

@ -1633,6 +1633,7 @@ sub read_recap {
%opt = (); %opt = ();
$saved_recap = _read_config(\%recap, $globals, "##\\s*$program-$version\\s*", $file); $saved_recap = _read_config(\%recap, $globals, "##\\s*$program-$version\\s*", $file);
%opt = %saved; %opt = %saved;
$recap{$_} //= {} for keys(%config);
for my $h (keys(%recap)) { for my $h (keys(%recap)) {
next if !exists($config{$h}); next if !exists($config{$h});
# Only status variables are copied from `%recap` into `%config` because the recap should # Only status variables are copied from `%recap` into `%config` because the recap should
@ -1647,8 +1648,13 @@ sub read_recap {
# `$recap{$h}{'status-ipv4'}` directly. # `$recap{$h}{'status-ipv4'}` directly.
for my $v (qw(atime mtime wtime ipv4 ipv6 status-ipv4 status-ipv6 for my $v (qw(atime mtime wtime ipv4 ipv6 status-ipv4 status-ipv6
warned-min-interval warned-min-error-interval)) { warned-min-interval warned-min-error-interval)) {
$config{$h}{$v} = $recap{$h}{$v} if exists($recap{$h}{$v}); if (exists($recap{$h}{$v})) {
$config{$h}{$v} = $recap{$h}{$v};
} else {
delete($config{$h}{$v});
}
} }
delete($recap{$h}) if !%{$recap{$h}};
} }
} }
###################################################################### ######################################################################

View file

@ -137,7 +137,6 @@ my @test_cases = (
'warned-min-error-interval' => $DOES_NOT_EXIST, 'warned-min-error-interval' => $DOES_NOT_EXIST,
# `var_a` should remain untouched. # `var_a` should remain untouched.
}}, }},
want_config_changes_TODO => "longstanding bug",
}, },
{ {
desc => "non-recap vars are not loaded to %recap or copied to %config", desc => "non-recap vars are not loaded to %recap or copied to %config",