summaryrefslogtreecommitdiffstats
path: root/lib/puppet/storage.rb
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-01-24 06:01:58 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-01-24 06:01:58 +0000
commitae2575b45de1e8f4c0ec956cebe0eed2bafbcf57 (patch)
tree9c2b7c839087c285c228374f525315e55c392a34 /lib/puppet/storage.rb
parent18e8e74a2e3b4c5d092fc0aae38bbc5455d4db48 (diff)
downloadpuppet-ae2575b45de1e8f4c0ec956cebe0eed2bafbcf57.tar.gz
puppet-ae2575b45de1e8f4c0ec956cebe0eed2bafbcf57.tar.xz
puppet-ae2575b45de1e8f4c0ec956cebe0eed2bafbcf57.zip
Adding the event-loop stuff to the repository and switching to using it. Also, breaking many classes out into their own class files.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@848 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/storage.rb')
-rw-r--r--lib/puppet/storage.rb12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/puppet/storage.rb b/lib/puppet/storage.rb
index a12a94178..0c06f5173 100644
--- a/lib/puppet/storage.rb
+++ b/lib/puppet/storage.rb
@@ -52,8 +52,8 @@ module Puppet
begin
@@state = YAML.load(file)
rescue => detail
- Puppet.err "Checksumfile %s is corrupt; replacing" %
- Puppet[:statefile]
+ Puppet.err "Checksumfile %s is corrupt (%s); replacing" %
+ [Puppet[:statefile], detail]
begin
File.rename(Puppet[:statefile],
Puppet[:statefile] + ".bad")
@@ -65,6 +65,11 @@ module Puppet
end
}
+ unless @@state.is_a?(Hash)
+ Puppet.err "State got corrupted"
+ self.init
+ end
+
#Puppet.debug "Loaded state is %s" % @@state.inspect
end
@@ -73,6 +78,7 @@ module Puppet
end
def self.store
+ Puppet.debug "Storing state"
unless FileTest.directory?(File.dirname(Puppet[:statefile]))
begin
Puppet.recmkdir(File.dirname(Puppet[:statefile]))
@@ -89,7 +95,7 @@ module Puppet
end
Puppet::Util.lock(
- Puppet[:statefile], File::CREAT|File::WRONLY, 0600
+ Puppet[:statefile], "w", 0600
) { |file|
file.print YAML.dump(@@state)
}