FM-2130 Move cache file to non temp directory

This commit is contained in:
Travis Fields 2015-01-09 14:09:03 -08:00
parent 413dafbb52
commit b11311ad65

View file

@ -15,7 +15,7 @@
class Facter::Util::DotD class Facter::Util::DotD
require 'yaml' require 'yaml'
def initialize(dir="/etc/facts.d", cache_file="/tmp/facts_cache.yml") def initialize(dir="/etc/facts.d", cache_file=File.join(Puppet[:libdir], "facts_dot_d.cache"))
@dir = dir @dir = dir
@cache_file = cache_file @cache_file = cache_file
@cache = nil @cache = nil
@ -23,7 +23,7 @@ class Facter::Util::DotD
end end
def entries def entries
Dir.entries(@dir).reject{|f| f =~ /^\.|\.ttl$/}.sort.map {|f| File.join(@dir, f) } Dir.entries(@dir).reject { |f| f =~ /^\.|\.ttl$/ }.sort.map { |f| File.join(@dir, f) }
rescue rescue
[] []
end end
@ -113,7 +113,7 @@ class Facter::Util::DotD
def cache_save! def cache_save!
cache = load_cache cache = load_cache
File.open(@cache_file, "w", 0600) {|f| f.write(YAML.dump(cache)) } File.open(@cache_file, "w", 0600) { |f| f.write(YAML.dump(cache)) }
rescue rescue
end end