summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xlib/puppet/loadedfile.rb6
-rwxr-xr-xtest/other/loadedfile.rb22
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$