esxi: let manifest file expire after 60s

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
 [ TL: fix wrong comparison with >= and avoid undef warning if file
   does not yet exist at all ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Wolfgang Bumiller
2024-03-11 13:13:19 +01:00
committed by Thomas Lamprecht
parent 814bde1958
commit 99ace9d447

View File

@ -105,12 +105,20 @@ my sub check_esxi_import_package : prototype() {
if !-e $ESXI_LIST_VMS;
}
my sub is_old : prototype($) {
my ($file) = @_;
my $mtime = (CORE::stat($file))[9];
return !defined($mtime) || ($mtime + 60) < CORE::time();
}
sub get_manifest : prototype($$$;$) {
my ($class, $storeid, $scfg, $force_query) = @_;
my $rundir = run_path($storeid);
my $manifest_file = "$rundir/manifest.json";
$force_query ||= is_old($manifest_file);
if (!$force_query && -e $manifest_file) {
return PVE::Storage::ESXiPlugin::Manifest->new(
file_get_contents($manifest_file),