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;