Module: DistributedCache::Utils

Defined in:
lib/distributed_cache/utils.rb

Class Method Summary collapse

Class Method Details

.rm_rf(dir) ⇒ Object

these folders could contain 100s of thousands of files faster to just mv the folder out of the way and delete it in a forked process



7
8
9
10
11
12
13
14
15
# File 'lib/distributed_cache/utils.rb', line 7

def self.rm_rf(dir)
  return unless File.exists?(dir)
  time = Time.now.to_i
  dest_dir = "#{dir}.#{time}"
  FileUtils.mv dir, dest_dir
  Process.fork do
    FileUtils.rm_rf dest_dir
  end
end

.tar(name, files) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/distributed_cache/utils.rb', line 17

def self.tar(name, files)
  if name[-3..-1] == 'tgz'
    `tar zcfh #{name} #{files}`
  else
    `tar cfh #{name} #{files}`
  end
end