summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2005-10-23 02:43:50 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2005-10-23 02:43:50 +0000
commitdf8dbbacb09b69c97aee0b76668fd3e56860eb38 (patch)
treefed2356556e0df9bba7bdb24d5b662a8e307e4af /lib
parente8912d51f1818bc59015ba687fbbb8a33fe91ecf (diff)
downloadpuppet-df8dbbacb09b69c97aee0b76668fd3e56860eb38.tar.gz
puppet-df8dbbacb09b69c97aee0b76668fd3e56860eb38.tar.xz
puppet-df8dbbacb09b69c97aee0b76668fd3e56860eb38.zip
fixing sources so that they always have a corresponding checksum state
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@728 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/type/pfile.rb7
-rwxr-xr-xlib/puppet/type/pfile/checksum.rb29
2 files changed, 23 insertions, 13 deletions
diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb
index 39198a286..5c78c4517 100644
--- a/lib/puppet/type/pfile.rb
+++ b/lib/puppet/type/pfile.rb
@@ -381,6 +381,8 @@ module Puppet
}
end
+ # This recurses against the remote source and makes sure the local
+ # and remote structures match. It's run after 'localrecurse'.
def sourcerecurse(recurse)
# FIXME sourcerecurse should support purging non-remote files
source = @states[:source].source
@@ -431,6 +433,11 @@ module Puppet
# a wrapper method to make sure the file exists before doing anything
def retrieve
if @states.include?(:source)
+ # This probably isn't the best place for it, but we need
+ # to make sure that we have a corresponding checksum state.
+ unless @states.include?(:checksum)
+ self[:checksum] = "md5"
+ end
@states[:source].retrieve
end
diff --git a/lib/puppet/type/pfile/checksum.rb b/lib/puppet/type/pfile/checksum.rb
index 8747cfeb5..addad4b50 100755
--- a/lib/puppet/type/pfile/checksum.rb
+++ b/lib/puppet/type/pfile/checksum.rb
@@ -18,6 +18,10 @@ module Puppet
@validtypes.include?(type)
end
+ def checktype
+ @checktypes[0]
+ end
+
def getsum(checktype)
sum = ""
case checktype
@@ -70,9 +74,14 @@ module Puppet
# Convert from the sum type to the stored checksum.
def shouldprocess(value)
+ unless defined? @checktypes
+ @checktypes = []
+ end
unless self.class.validtype?(value)
raise Puppet::Error, "Invalid checksum type '%s'" % value
end
+
+ @checktypes << value
state = Puppet::Storage.state(self)
if hash = state[@parent[:path]]
if hash.include?(value)
@@ -95,23 +104,17 @@ module Puppet
# mechanism can really only test against one, so we'll just retrieve
# the first specified sum type.
def retrieve
- checktypes = nil
- if defined? @shouldorig
- checktypes = @shouldorig
- else
- checktypes = ["md5"]
+ unless defined? @checktypes
+ @checktypes = ["md5"]
end
unless FileTest.exists?(@parent.name)
- Puppet.err "File %s does not exist" % @parent.name
self.is = :notfound
return
end
# Just use the first allowed check type
- @checktype = checktypes[0]
-
- @is = getsum(@checktype)
+ @is = getsum(@checktypes[0])
# If there is no should defined, then store the current value
# into the 'should' value, so that we're not marked as being
@@ -191,7 +194,7 @@ module Puppet
end
# if we're replacing, vs. updating
- if state[@parent.name].include?(@checktype)
+ if state[@parent.name].include?(@checktypes[0])
unless defined? @should
raise Puppet::Error.new(
("@should is not initialized for %s, even though we " +
@@ -199,15 +202,15 @@ module Puppet
)
end
Puppet.debug "Replacing %s checksum %s with %s" %
- [@parent.name, state[@parent.name][@checktype],@is]
+ [@parent.name, state[@parent.name][@checktypes[0]],@is]
#Puppet.debug "@is: %s; @should: %s" % [@is,@should]
result = true
else
Puppet.debug "Creating checksum %s for %s of type %s" %
- [self.is,@parent.name,@checktype]
+ [self.is,@parent.name,@checktypes[0]]
result = false
end
- state[@parent.name][@checktype] = @is
+ state[@parent.name][@checktypes[0]] = @is
return result
end
end