Skip to content

Commit

Permalink
FM-2130 Move cache file to non temp directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis Fields committed Jan 14, 2015
1 parent 80f0962 commit e32afd7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/facter/facter_dot_d.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
class Facter::Util::DotD
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
@cache_file = cache_file
@cache = nil
@types = {".txt" => :txt, ".json" => :json, ".yaml" => :yaml}
end

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
[]
end
Expand Down Expand Up @@ -113,7 +113,7 @@ def script_parser(file)

def cache_save!
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
end

Expand Down

0 comments on commit e32afd7

Please sign in to comment.