summaryrefslogtreecommitdiffstats
path: root/lib/puppet/util/autoload/file_cache.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/util/autoload/file_cache.rb')
-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