]> gitweb.fluxo.info Git - puppet-stdlib.git/commitdiff
FM-2130 Move cache file to non temp directory
authorTravis Fields <travis@puppetlabs.com>
Fri, 9 Jan 2015 22:09:03 +0000 (14:09 -0800)
committerTravis Fields <travis@puppetlabs.com>
Wed, 14 Jan 2015 20:39:14 +0000 (12:39 -0800)
lib/facter/facter_dot_d.rb

index 2c096b049d6630e750ac6fdb2bf065e90d86c8d7..b0584370a7950dc39d8bbee5263e580f551ecb0a 100644 (file)
@@ -15,7 +15,7 @@
 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
@@ -23,7 +23,7 @@ class Facter::Util::DotD
   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
@@ -113,7 +113,7 @@ class Facter::Util::DotD
 
   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