diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-01-03 19:43:42 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-01-03 19:43:42 +0000 |
commit | 0ef89715c590137299e89496bf6ee09d97a8b2b2 (patch) | |
tree | 4c8818a59ff0b37988f5ed786520c694e8357136 | |
parent | f58bda2b0bde6b4c1b464d058ada31df4a7ea3b4 (diff) | |
download | puppet-0ef89715c590137299e89496bf6ee09d97a8b2b2.tar.gz puppet-0ef89715c590137299e89496bf6ee09d97a8b2b2.tar.xz puppet-0ef89715c590137299e89496bf6ee09d97a8b2b2.zip |
Fixing #394. LoadedFile was not checking to see if files went missing.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2026 980ebf18-57e1-0310-9a29-db15c13687c0
-rwxr-xr-x | lib/puppet/loadedfile.rb | 6 | ||||
-rwxr-xr-x | test/other/loadedfile.rb | 22 |
2 files changed, 27 insertions, 1 deletions
diff --git a/lib/puppet/loadedfile.rb b/lib/puppet/loadedfile.rb index c14bcc195..cfd666e36 100755 --- a/lib/puppet/loadedfile.rb +++ b/lib/puppet/loadedfile.rb @@ -53,7 +53,11 @@ module Puppet def stamp if @stamp.nil? or (Time.now.to_i - @statted >= Puppet[:filetimeout]) @statted = Time.now.to_i - @stamp = File.stat(@file).ctime + begin + @stamp = File.stat(@file).ctime + rescue Errno::ENOENT + @stamp = Time.now + end end return @stamp end diff --git a/test/other/loadedfile.rb b/test/other/loadedfile.rb index 117c967a2..353bacd16 100755 --- a/test/other/loadedfile.rb +++ b/test/other/loadedfile.rb @@ -79,6 +79,28 @@ class TestLoadedFile < Test::Unit::TestCase assert_equal(File.stat(file).ctime, obj.stamp, "File did not refresh") end + + # Testing #394. + def test_changed_missing_file + file = tempfile() + File.open(file, "w") { |f| f.puts "" } + obj = nil + assert_nothing_raised { + obj = Puppet::LoadedFile.new(file) + } + Puppet[:filetimeout] = -10 + + assert_nothing_raised { + obj.changed? + } + + # Now remove the file + File.unlink(file) + + assert_nothing_raised("removed file threw an error") { + assert(obj.changed?, "File was not considered changed when missing") + } + end end # $Id$ |