[pve-devel] [PATCH manager 2/2] aplinfo: use explicit defined checks
Fabian Grünbichler
f.gruenbichler at proxmox.com
Wed Aug 24 12:27:42 CEST 2016
a checksum of '0' can never be correct, but this makes the code clearer
---
PVE/API2/Nodes.pm | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
index 96cec22..6db6caf 100644
--- a/PVE/API2/Nodes.pm
+++ b/PVE/API2/Nodes.pm
@@ -1116,10 +1116,12 @@ __PACKAGE__->register_method({
eval {
open(my $fh, '<', $filename) or die "Can't open '$filename': $!";
binmode($fh);
- if ($expected = $template_info->{sha512sum}) {
+ if (defined($template_info->{sha512sum})) {
+ $expected = $template_info->{sha512sum};
$digest = Digest::SHA->new(512)->addfile($fh)->hexdigest;
- } elsif ($expected = $template_info->{md5sum}) {
+ } elsif (defined($template_info->{md5sum})) {
#fallback to MD5
+ $expected = $template_info->{md5sum};
$digest = Digest::MD5->new->addfile($fh)->hexdigest;
} else {
die "no expected checksum defined";
--
2.1.4
More information about the pve-devel
mailing list