]> git.proxmox.com Git - pve-storage.git/commitdiff
Fix digest handling
authorDietmar Maurer <dietmar@proxmox.com>
Wed, 7 Sep 2011 10:01:25 +0000 (12:01 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 7 Sep 2011 10:01:25 +0000 (12:01 +0200)
PVE/API2/Storage/Config.pm
PVE/Storage.pm

index 3a6c6bca4a0447d60c1b01ef11d115b5bb147930..7d3826e19173d83b534a449d64f7c6598a29eb8a 100755 (executable)
@@ -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,
            }
        },
index 7ee17c36bcb9f8a3b719986a1dfac8c152869b88..64b4c74a78cbc211f0d337281f307a6e13ffb6b4 100755 (executable)
@@ -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;