summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2009-08-19 17:06:41 -0700
committerJames Turnbull <james@lovedthanlost.net>2009-08-23 13:20:11 +1000
commitff39bc707e7f37ddeb28203a9e1bfaddcb9dc641 (patch)
tree9bdc5090dd695e97c7bb340b1d4250471a042685 /lib
parent47dee83464cd2ba95c931e1e4f7d2a018225c351 (diff)
downloadpuppet-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-xlib/puppet/type/file/content.rb13
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;