Method: TargetIO::Deploy#deploy

Defined in:
lib/chef/file_content_management/deploy/target_io.rb

#deploy(src, dst) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/chef/file_content_management/deploy/target_io.rb', line 8

def deploy(src, dst)
  Chef::Log.trace("Reading modes from remote file #{dst}")
  stat = ::TargetIO::File.stat(dst)
  mode = stat.mode & 07777
  uid  = stat.uid
  gid  = stat.gid

  Chef::Log.trace("Uploading local temporary file #{src} as remote file #{dst}")
  ::TargetIO::File.upload(src, dst)

  Chef::Log.trace("Applying mode = #{mode.to_s(8)}, uid = #{uid}, gid = #{gid} to #{dst}")
  ::TargetIO::File.chown(uid, nil, dst)
  ::TargetIO::File.chown(nil, gid, dst)
  ::TargetIO::File.chmod(mode, dst)

  # Local clean up
  File.delete(src)
end