5to6: get_pkg: cache version list

this is a short running script, so the version list can be re-used,
the chance that there where updates in between are slim and racy
anyway. IF getting the versions did not succeeded, we still retry on
every call though, simpler and ensures a warning is printed in the
caller check vicinity.

Makes script noticeable faster.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2019-06-28 08:42:19 +02:00
parent f034380db0
commit 7d1b353b09

View File

@ -80,10 +80,11 @@ sub print_header {
$print_header_first = 0;
}
my $versions;
my $get_pkg = sub {
my ($pkg) = @_;
my $versions = eval { PVE::API2::APT->versions({ node => $nodename }); };
$versions = eval { PVE::API2::APT->versions({ node => $nodename }) } if !defined($versions);
if (!defined($versions)) {
my $msg = "unable to retrieve package version information";