# File lib/puppet/util/storage.rb, line 46
46:   def self.load
47:     Puppet.settings.use(:main) unless FileTest.directory?(Puppet[:statedir])
48: 
49:     unless File.exists?(Puppet[:statefile])
50:       self.init unless !@@state.nil?
51:       return
52:     end
53:     unless File.file?(Puppet[:statefile])
54:       Puppet.warning("Checksumfile #{Puppet[:statefile]} is not a file, ignoring")
55:       return
56:     end
57:     Puppet::Util.benchmark(:debug, "Loaded state") do
58:       Puppet::Util::FileLocking.readlock(Puppet[:statefile]) do |file|
59:         begin
60:           @@state = YAML.load(file)
61:         rescue => detail
62:           Puppet.err "Checksumfile #{Puppet[:statefile]} is corrupt (#{detail}); replacing"
63:           begin
64:             File.rename(Puppet[:statefile], Puppet[:statefile] + ".bad")
65:           rescue
66:             raise Puppet::Error,
67:               "Could not rename corrupt #{Puppet[:statefile]}; remove manually"
68:           end
69:         end
70:       end
71:     end
72: 
73:     unless @@state.is_a?(Hash)
74:       Puppet.err "State got corrupted"
75:       self.init
76:     end
77: 
78:     #Puppet.debug "Loaded state is #{@@state.inspect}"
79:   end