From dfe98e643767cd9648377f013251adfc16d54b8f Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 7 Sep 2011 12:01:25 +0200 Subject: [PATCH] Fix digest handling --- PVE/API2/Storage/Config.pm | 2 ++ PVE/Storage.pm | 6 +----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/PVE/API2/Storage/Config.pm b/PVE/API2/Storage/Config.pm index 3a6c6bc..7d3826e 100755 --- a/PVE/API2/Storage/Config.pm +++ b/PVE/API2/Storage/Config.pm @@ -254,6 +254,8 @@ __PACKAGE__->register_method ({ }, digest => { type => 'string', + description => 'Prevent changes if current configuration file has different SHA1 digest. This can be used to prevent concurrent modifications.', + maxLength => 40, optional => 1, } }, diff --git a/PVE/Storage.pm b/PVE/Storage.pm index 7ee17c3..64b4c74 100755 --- a/PVE/Storage.pm +++ b/PVE/Storage.pm @@ -425,15 +425,13 @@ sub parse_config { my $ids = {}; - my $sha1 = Digest::SHA1->new; + my $digest = Digest::SHA1::sha1_hex($raw); my $pri = 0; while ($raw && $raw =~ s/^(.*?)(\n|$)//) { my $line = $1; - $sha1->add ($line); # compute digest - next if $line =~ m/^\#/; next if $line =~ m/^\s*$/; @@ -526,8 +524,6 @@ sub parse_config { } } - my $digest = $sha1->hexdigest; - my $cfg = { ids => $ids, digest => $digest}; return $cfg;