ruby - net::scp copy/overwriting folder -
say copy folder f_1 local machine target machine m_1 /tmp directory mf_1.
console: [root@m_1 tmp] ls -a | grep mf_1 # => doesn't exist irb: options = {recursive: true} net::scp.upload!(host, user, '~/f_1', '/tmp/mf_1', options) console: [root@m_1 tmp] ls -a | grep mf_1 # => folder exists, fine # then, if try overwrite existing folder... irb: net::scp.upload!(host, user, '~/f_1', '/tmp/mf_1', options) console: [root@m_1 tmp] ls -a | grep mf_1 # => folder exists [root@m_1 tmp] cd mf_1 [root@m_1 m_f1] ls # => f_1 => /tmp/mf_1/f_1 so, instead of mf_1 being overwritten folder copied inside of /tmp/mf_1, resulting in /tmp/mf_1/f_1.
the question pretty simple, how preserve behavior it's consistent , calling
net::scp.upload!(host, user, '~/f_1', '/tmp/mf_1', options) twice in row act same way both when folder exists , doesn't?
i ended adding dot, if source dir.
not ideal, here's example:
options = {recursive: true} # target /tmp/mf_1 doesn't exist net::scp.upload!(host, user, '~/f_1/.', '/tmp/mf_1', options) # target /tmp/mf_1 has been created # second time net::scp.upload!(host, user, '~/f_1/.', '/tmp/mf_1', options) # target /tmp/mf_1 has been overwritten # not dir, files in it, want
Comments
Post a Comment