diff options
author | Markus Roberts <Markus@reality.com> | 2009-08-19 17:06:41 -0700 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2009-08-23 13:20:11 +1000 |
commit | ff39bc707e7f37ddeb28203a9e1bfaddcb9dc641 (patch) | |
tree | 9bdc5090dd695e97c7bb340b1d4250471a042685 /lib | |
parent | 47dee83464cd2ba95c931e1e4f7d2a018225c351 (diff) | |
download | puppet-ff39bc707e7f37ddeb28203a9e1bfaddcb9dc641.tar.gz puppet-ff39bc707e7f37ddeb28203a9e1bfaddcb9dc641.tar.xz puppet-ff39bc707e7f37ddeb28203a9e1bfaddcb9dc641.zip |
Fixes #2550 Handles case where metadata is nil
The checksum function assumed that if the source was present the
metadata (including checksum) was also, and thus that the type of
the checksum could be extracated with a simple RegExp match. When
metadata is nil it returns nil for the source checksum and the
modified function passes this on.
Alternatives would be to default to :md5 or to pass on to checking
the :checksum parameter as if there were no source.
Signed-off-by: Markus Roberts <Markus@reality.com>
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/puppet/type/file/content.rb | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/puppet/type/file/content.rb b/lib/puppet/type/file/content.rb index f30833bd0..d571e469b 100755 --- a/lib/puppet/type/file/content.rb +++ b/lib/puppet/type/file/content.rb @@ -38,18 +38,17 @@ module Puppet def checksum_type if source = resource.parameter(:source) - source.checksum =~ /^\{(\w+)\}.+/ - return $1.to_sym + result = source.checksum elsif checksum = resource.parameter(:checksum) result = checksum.checktype - if result =~ /^\{(\w+)\}.+/ - return $1.to_sym - else - return result - end else return :md5 end + if result =~ /^\{(\w+)\}.+/ + return $1.to_sym + else + return result + end end # If content was specified, return that; else try to return the source content; |