Fix digest handling
This commit is contained in:
@ -254,6 +254,8 @@ __PACKAGE__->register_method ({
|
|||||||
},
|
},
|
||||||
digest => {
|
digest => {
|
||||||
type => 'string',
|
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,
|
optional => 1,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -425,15 +425,13 @@ sub parse_config {
|
|||||||
|
|
||||||
my $ids = {};
|
my $ids = {};
|
||||||
|
|
||||||
my $sha1 = Digest::SHA1->new;
|
my $digest = Digest::SHA1::sha1_hex($raw);
|
||||||
|
|
||||||
my $pri = 0;
|
my $pri = 0;
|
||||||
|
|
||||||
while ($raw && $raw =~ s/^(.*?)(\n|$)//) {
|
while ($raw && $raw =~ s/^(.*?)(\n|$)//) {
|
||||||
my $line = $1;
|
my $line = $1;
|
||||||
|
|
||||||
$sha1->add ($line); # compute digest
|
|
||||||
|
|
||||||
next if $line =~ m/^\#/;
|
next if $line =~ m/^\#/;
|
||||||
next if $line =~ m/^\s*$/;
|
next if $line =~ m/^\s*$/;
|
||||||
|
|
||||||
@ -526,8 +524,6 @@ sub parse_config {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
my $digest = $sha1->hexdigest;
|
|
||||||
|
|
||||||
my $cfg = { ids => $ids, digest => $digest};
|
my $cfg = { ids => $ids, digest => $digest};
|
||||||
|
|
||||||
return $cfg;
|
return $cfg;
|
||||||
|
|||||||
Reference in New Issue
Block a user