write_recap: Move warned-min-*
recap sync to where they are set
This is a step toward separating `%recap` from `%config`.
This commit is contained in:
parent
1a748e7a86
commit
e478117d4e
1 changed files with 11 additions and 17 deletions
20
ddclient.in
20
ddclient.in
|
@ -1559,30 +1559,20 @@ sub write_recap {
|
||||||
my ($file) = @_;
|
my ($file) = @_;
|
||||||
|
|
||||||
for my $h (keys %config) {
|
for my $h (keys %config) {
|
||||||
my $vars = $protocols{opt('protocol', $h)}{variables};
|
|
||||||
# nic_updateable (called from update_nics for each host) sets `$config{$h}{update}`
|
# nic_updateable (called from update_nics for each host) sets `$config{$h}{update}`
|
||||||
# according to whether an update was attempted.
|
# according to whether an update was attempted.
|
||||||
#
|
next if !$config{$h}{'update'};
|
||||||
|
delete($config{$h}{'update'});
|
||||||
|
my $vars = $protocols{opt('protocol', $h)}{variables};
|
||||||
# Entries in `%recap` with `undef` values are deleted to avoid needing to figure out how to
|
# Entries in `%recap` with `undef` values are deleted to avoid needing to figure out how to
|
||||||
# represent `undef` in the cache file and to simplify testing. Also, entries for non-recap
|
# represent `undef` in the cache file and to simplify testing. Also, entries for non-recap
|
||||||
# variables (which can happen after changing a host's protocol or after switching to a
|
# variables (which can happen after changing a host's protocol or after switching to a
|
||||||
# different version of ddclient) are deleted.
|
# different version of ddclient) are deleted.
|
||||||
if ($config{$h}{'update'}) {
|
|
||||||
delete($config{$h}{'update'});
|
|
||||||
$recap{$h} = {};
|
$recap{$h} = {};
|
||||||
for my $v (keys(%$vars)) {
|
for my $v (keys(%$vars)) {
|
||||||
next if !$vars->{$v}{recap} || !defined(opt($v, $h));
|
next if !$vars->{$v}{recap} || !defined(opt($v, $h));
|
||||||
$recap{$h}{$v} = opt($v, $h);
|
$recap{$h}{$v} = opt($v, $h);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
for my $v (qw(warned-min-interval warned-min-error-interval)) {
|
|
||||||
if ($vars->{$v} && $vars->{$v}{recap} && defined(my $val = opt($v, $h))) {
|
|
||||||
$recap{$h}{$v} = $val;
|
|
||||||
} else {
|
|
||||||
delete($recap{$h}{$v});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
my $recap = "";
|
my $recap = "";
|
||||||
|
@ -3537,6 +3527,7 @@ sub nic_updateable {
|
||||||
if opt('verbose') || !($config{$host}{'warned-min-interval'} // 0);
|
if opt('verbose') || !($config{$host}{'warned-min-interval'} // 0);
|
||||||
|
|
||||||
$config{$host}{'warned-min-interval'} = $now;
|
$config{$host}{'warned-min-interval'} = $now;
|
||||||
|
$recap{$host}{'warned-min-interval'} = $now;
|
||||||
|
|
||||||
} elsif (($recap{$host}{'status-ipv4'} // '') ne 'good' &&
|
} elsif (($recap{$host}{'status-ipv4'} // '') ne 'good' &&
|
||||||
!interval_expired($host, 'atime', 'min-error-interval')) {
|
!interval_expired($host, 'atime', 'min-error-interval')) {
|
||||||
|
@ -3552,6 +3543,7 @@ sub nic_updateable {
|
||||||
}
|
}
|
||||||
|
|
||||||
$config{$host}{'warned-min-error-interval'} = $now;
|
$config{$host}{'warned-min-error-interval'} = $now;
|
||||||
|
$recap{$host}{'warned-min-error-interval'} = $now;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$update = 1;
|
$update = 1;
|
||||||
|
@ -3564,6 +3556,7 @@ sub nic_updateable {
|
||||||
if opt('verbose') || !($config{$host}{'warned-min-interval'} // 0);
|
if opt('verbose') || !($config{$host}{'warned-min-interval'} // 0);
|
||||||
|
|
||||||
$config{$host}{'warned-min-interval'} = $now;
|
$config{$host}{'warned-min-interval'} = $now;
|
||||||
|
$recap{$host}{'warned-min-interval'} = $now;
|
||||||
|
|
||||||
} elsif (($recap{$host}{'status-ipv6'} // '') ne 'good' &&
|
} elsif (($recap{$host}{'status-ipv6'} // '') ne 'good' &&
|
||||||
!interval_expired($host, 'atime', 'min-error-interval')) {
|
!interval_expired($host, 'atime', 'min-error-interval')) {
|
||||||
|
@ -3579,6 +3572,7 @@ sub nic_updateable {
|
||||||
}
|
}
|
||||||
|
|
||||||
$config{$host}{'warned-min-error-interval'} = $now;
|
$config{$host}{'warned-min-error-interval'} = $now;
|
||||||
|
$recap{$host}{'warned-min-error-interval'} = $now;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$update = 1;
|
$update = 1;
|
||||||
|
|
Loading…
Reference in a new issue