diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-02-08 17:44:44 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-02-08 17:44:44 +0000 |
commit | ccd0121db4e8e1f0bf162332241884b22ff724b4 (patch) | |
tree | 655aa2d23141202243964ce4d3be951da5f22737 /lib | |
parent | 8eab733e2529434528d7ebda6a883151964dd7b9 (diff) | |
download | puppet-ccd0121db4e8e1f0bf162332241884b22ff724b4.tar.gz puppet-ccd0121db4e8e1f0bf162332241884b22ff724b4.tar.xz puppet-ccd0121db4e8e1f0bf162332241884b22ff724b4.zip |
Fixing small problem where checksum retrieving did not look in the cache; this was only ever a problem in cases where checksums have no "should" value set, which is generally only the case on the fileserver, but it caused the fileserver to replace checksum values on every retrieval.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@885 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/puppet/type/pfile/checksum.rb | 77 | ||||
-rwxr-xr-x | lib/puppet/type/pfile/ensure.rb | 1 | ||||
-rwxr-xr-x | lib/puppet/type/pfile/source.rb | 10 |
3 files changed, 39 insertions, 49 deletions
diff --git a/lib/puppet/type/pfile/checksum.rb b/lib/puppet/type/pfile/checksum.rb index 292470d62..33ef14d9b 100755 --- a/lib/puppet/type/pfile/checksum.rb +++ b/lib/puppet/type/pfile/checksum.rb @@ -49,6 +49,35 @@ module Puppet end end + # Retrieve the cached sum + def getcachedsum + hash = nil + unless hash = @parent.cached(:checksums) + hash = {} + @parent.cache(:checksums, hash) + end + + sumtype = @checktypes[0] + + #unless state + # self.devfail "Did not get state back from Storage" + #end + + if hash.include?(sumtype) + #self.notice "Found checksum %s for %s" % + # [hash[sumtype] ,@parent[:path]] + return hash[sumtype] + elsif hash.empty? + #self.notice "Could not find sum of type %s" % sumtype + return :nosum + else + #self.notice "Found checksum for %s but not of type %s" % + # [@parent[:path],sumtype] + return :nosum + end + end + + # Calculate the sum from disk. def getsum(checktype) sum = "" case checktype @@ -117,44 +146,7 @@ module Puppet @checktypes << value - hash = nil - unless hash = @parent.cached(:checksums) - hash = {} - @parent.cache(:checksums, hash) - end - - #unless state - # self.devfail "Did not get state back from Storage" - #end - - if hash.include?(value) - #self.notice "Found checksum %s for %s" % - # [hash[value] ,@parent[:path]] - return hash[value] - elsif hash.empty? - #self.notice "Could not find sum of type %s" % @checktypes[0] - return :nosum - else - #self.notice "Found checksum for %s but not of type %s" % - # [@parent[:path],@checktypes[0]] - return :nosum - end -# if hash = state[@parent[:path]] -# if hash.include?(value) -# #self.notice "Found checksum %s for %s" % -# # [hash[value] ,@parent[:path]] -# return hash[value] -# else -# #self.notice "Found checksum for %s but not of type %s" % -# # [@parent[:path],@checktypes[0]] -# return :nosum -# end -# else -# # We can't use :absent here, because then it'll match on -# # non-existent files -# #self.notice "Could not find sum of type %s" % @checktypes[0] -# return :nosum -# end + return getcachedsum() end # Even though they can specify multiple checksums, the insync? @@ -178,11 +170,18 @@ module Puppet # Just use the first allowed check type @is = getsum(@checktypes[0]) + # @should should always be set, so if it's not set at all, we + # know we haven't looked in the cache yet. + unless defined? @should and ! @should.nil? + @should = [getcachedsum()] + end + # If there is no should defined, then store the current value # into the 'should' value, so that we're not marked as being # out of sync. We don't want to generate an event the first # time we get a sum. - if ! defined? @should or @should == [:nosum] + if @should == [:nosum] + self.warning "updatingness from %s" % @should.inspect @should = [@is] # FIXME we should support an updatechecksums-like mechanism self.updatesum diff --git a/lib/puppet/type/pfile/ensure.rb b/lib/puppet/type/pfile/ensure.rb index 74a75808e..4659b44fe 100755 --- a/lib/puppet/type/pfile/ensure.rb +++ b/lib/puppet/type/pfile/ensure.rb @@ -56,6 +56,7 @@ module Puppet Dir.mkdir(@parent.name) end } + @parent.setchecksum return :directory_created end diff --git a/lib/puppet/type/pfile/source.rb b/lib/puppet/type/pfile/source.rb index 4244080dd..0370106df 100755 --- a/lib/puppet/type/pfile/source.rb +++ b/lib/puppet/type/pfile/source.rb @@ -129,16 +129,6 @@ module Puppet end @should = [@stats[:checksum]] - - #if state = @parent.state(:ensure) - # unless state.should == "file" - # self.notice( - # "File %s had both create and source enabled" % - # @parent.name - # ) - # @parent.delete(:ensure) - # end - #end # If we're a directory, then do not copy anything, and instead just # create the directory using the 'create' state. when "directory": |