summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-08-07 17:39:44 -0700
committerJames Turnbull <james@lovedthanlost.net>2009-08-10 17:36:17 +1000
commit0cb9072c0e3b37332f4eeaeff061950d6f73d021 (patch)
treebb813907b006c28601117fc939887cd437a21485 /lib/puppet
parent23948d0b7efb482f891a333d4af56dc5ac59c00f (diff)
downloadpuppet-0cb9072c0e3b37332f4eeaeff061950d6f73d021.tar.gz
puppet-0cb9072c0e3b37332f4eeaeff061950d6f73d021.tar.xz
puppet-0cb9072c0e3b37332f4eeaeff061950d6f73d021.zip
Fixing #2541 - file cache is more resilient to failure
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/util/autoload/file_cache.rb20
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/puppet/util/autoload/file_cache.rb b/lib/puppet/util/autoload/file_cache.rb
index 12400f620..4ad0c7f39 100644
--- a/lib/puppet/util/autoload/file_cache.rb
+++ b/lib/puppet/util/autoload/file_cache.rb
@@ -23,7 +23,7 @@ module Puppet::Util::Autoload::FileCache
cache = cached_data?(path, :directory?)
return cache unless cache.nil?
- begin
+ protect(path) do
stat = File.lstat(path)
if stat.directory?
found_file(path, stat)
@@ -32,9 +32,6 @@ module Puppet::Util::Autoload::FileCache
missing_file(path)
return false
end
- rescue Errno::ENOENT
- missing_file(path)
- return false
end
end
@@ -42,13 +39,10 @@ module Puppet::Util::Autoload::FileCache
cache = cached_data?(path)
return cache unless cache.nil?
- begin
+ protect(path) do
stat = File.lstat(path)
found_file(path, stat)
return true
- rescue Errno::ENOENT
- missing_file(path)
- return false
end
end
@@ -108,4 +102,14 @@ module Puppet::Util::Autoload::FileCache
def data_expired?(time)
Time.now - time > 15
end
+
+ def protect(path)
+ begin
+ yield
+ rescue => detail
+ raise unless detail.class.to_s.include?("Errno")
+ missing_file(path)
+ return false
+ end
+ end
end