Method: Atomos.default_tmpdir_for_file

Defined in:
lib/atomos.rb

.default_tmpdir_for_file(dest, tmpdir) ⇒ Object

rubocop:enable Metrics/MethodLength



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/atomos.rb', line 33

def self.default_tmpdir_for_file(dest, tmpdir)
  tmpdir ||= begin
    require 'tmpdir'
    Dir.tmpdir
  end

  # Ensure the destination is on the same device as tmpdir
  if File.stat(tmpdir).dev != File.stat(File.dirname(dest)).dev
    # If not, use the directory of the destination as the tmpdir.
    tmpdir = File.dirname(dest)
  end

  tmpdir
end