[pve-devel] applied: [PATCH manager] 5to6: get_pkg: cache version list

Thomas Lamprecht t.lamprecht at proxmox.com
Fri Jun 28 08:45:23 CEST 2019


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 at proxmox.com>
---
 PVE/CLI/pve5to6.pm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/PVE/CLI/pve5to6.pm b/PVE/CLI/pve5to6.pm
index 1a92a473..440c58e6 100644
--- a/PVE/CLI/pve5to6.pm
+++ b/PVE/CLI/pve5to6.pm
@@ -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";
-- 
2.20.1





More information about the pve-devel mailing list