From ff39bc707e7f37ddeb28203a9e1bfaddcb9dc641 Mon Sep 17 00:00:00 2001 From: Markus Roberts Date: Wed, 19 Aug 2009 17:06:41 -0700 Subject: 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 --- lib/puppet/type/file/content.rb | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'lib/puppet') 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; -- cgit