Method: ConfCtl::ConfCache#update
- Defined in:
- lib/confctl/conf_cache.rb
#update ⇒ Object
Update cache file with the current state of the configuration directory
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/confctl/conf_cache.rb', line 46 def update @files.clear list_files.each do |file| begin st = File.lstat(file) rescue Errno::ENOENT next end @files[file] = { 'mtime' => st.mtime.to_i, 'size' => st.size } end tmp = "#{@cache_file}.new" FileUtils.mkpath(@cache_dir) File.write(tmp, { 'files' => @files }.to_json) File.rename(tmp, @cache_file) @uptodate = true end |