pyinfra-dev / pyinfra

pyinfra turns Python code into shell commands and runs them on your servers. Execute ad-hoc commands and write declarative operations. Target SSH servers, local machine and Docker containers. Fast and scales from one server to thousands.
https://pyinfra.com
MIT License
3.84k stars 374 forks source link

using file.sync in a folder with symlinks on it #844

Open alexjp opened 2 years ago

alexjp commented 2 years ago

Describe the bug

I am trying to sync a folder with a symlink on it. It seems pyinfra replaces the symlink into the "symlink destination" or ignores the symlink if its to a folder.

To Reproduce

create a folder "test" create file "test/1" and folder "test/a" cd "test" and do "ln -s 1 2" and "ln -s a b"

pyinfra will copy the files 1 and replace symlink 2 with the destination, this case 1. pyinfra will ignore the symlink b

Expected behavior

it would be expected that it would have the symlinks 2 and b, like they are in the source folder.

Meta

Thanks for pyinfra, i am very new to it, but seems very cool!

sysadmin75 commented 2 years ago

If you use files.rsync, this will preserve your symlink structure. I just tested this and it works.

alexjp commented 2 years ago

thanks @sysadmin75 !

I was thinking on using files.sync, because the documentation says that : "The files.rsync operation is in alpha, and only supported using SSH or @local connectors.".

Fizzadar commented 2 years ago

Thank you for raising this issue @alexjp! Currently files.sync doesn't have any handling for links - but it definitely should copy the links as-is!

Sidenote: I'm also going to bump the rsync operation to beta because it's stable, albeit not as well tested as others (incl files.sync).

alexjp commented 2 years ago

thanks !

and also thanks for marking rsync as beta also :)