put(): treat trailing slash on local_path similary to rsync #579

Closed
wants to merge 1 commit into
from

Projects

None yet

2 participants

@bpowers
bpowers commented Mar 8, 2012

This allows us to do:
put('src/foo/', 'dst/bar')

rathern than:
put('src/foo', 'dst')
run('mv dst/foo dst/bar')

Signed-off-by: Bobby Powers bobbypowers@gmail.com

@bpowers bpowers put(): treat trailing slash on local_path similary to rsync
This allows us to do:
put('src/foo/', 'dst/bar')

rathern than:
put('src/foo', 'dst')
run('mv dst/foo dst/bar')

Signed-off-by: Bobby Powers <bobbypowers@gmail.com>
9c2d4d7
@bpowers
bpowers commented Mar 8, 2012

I probably should add tests for this. I'll do that if the idea looks mergeable to you

@bitprophet
Member

Thanks for the ticket!

We generally try to make put/get act like vanilla SCP in terms of how it treats args, so unless scp src/foo/ dst behaves like you mention vs behaving like scp src/foo dst, it's probably not a great idea IMO. (Feel free to fact check this!)

There have been ideas kicked around to allow different backends for put, where you could say "I'd like to use rsync instead of scp" and then the args would probably use rsync semantics like you describe. That's #520.

@bitprophet bitprophet closed this Mar 10, 2012
@bpowers
bpowers commented Mar 13, 2012

okay, well it doesn't work like vanilla scp right now. What I want to be able to do in one step is:

$ scp -r ~/a/b remote:c

and when c doesn't exist, it is created. The problem is that with scp, when c does exist, b is copied into c:

[bpowers@fina ~]$ ssh boosd.org ls -l tmp
total 0
[bpowers@fina ~]$ scp -r tmp/b boosd.org:tmp/c
x                                             100%    0     0.0KB/s   00:00    
y                                             100%    0     0.0KB/s   00:00    
z                                             100%    0     0.0KB/s   00:00    
[bpowers@fina ~]$ ssh boosd.org ls -l tmp
total 4
drwxrwxr-x. 2 bpowers bpowers 4096 Mar 12 21:50 c
[bpowers@fina ~]$ scp -r tmp/b boosd.org:tmp/c
x                                             100%    0     0.0KB/s   00:00    
y                                             100%    0     0.0KB/s   00:00    
z                                             100%    0     0.0KB/s   00:00    
[bpowers@fina ~]$ ssh boosd.org ls -l tmp/c
total 4 
drwxrwxr-x. 2 bpowers bpowers 4096 Mar 12 21:50 b
-rw-rw-r--. 1 bpowers bpowers    0 Mar 12 21:50 x
-rw-rw-r--. 1 bpowers bpowers    0 Mar 12 21:50 y
-rw-rw-r--. 1 bpowers bpowers    0 Mar 12 21:50 z

I don't really like that this makes the operation non-idempotent, but if it is preferable because it is what scp does I can whip up a patch. Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment