stephenh / mirror

A tool for real-time, two-way sync for remote (e.g. desktop/laptop) development
Apache License 2.0
391 stars 37 forks source link

Support syncing file permissions and ownership #39

Open masiqbal opened 5 years ago

masiqbal commented 5 years ago

Hello,

Thank you for this great software. I just installed and run it easily.

The bidirectional synchronization works great, except it can not sync file permission and ownership. Am I missed something or it is not supported?

Warms Regards

stephenh commented 5 years ago

Hi, yeah, that is generally/intentionally not supported. My rationale was that:

1) unix permissions are usually id-based, and its unlikely ids match across machines (granted, I could resolve the id to a user/group name, and then lookup that user/group name on the other side)

2) the client/server may be different platforms

3) I typically run mirror as a user-level program anyway (i.e. not a daemon), with the right user I want to own the permissions anyway (i.e. my personal user on the client, and my personal user on the server), which makes the default file permissions work out.

masiqbal commented 5 years ago

Yeah, that makes perfect sense. But if there are options to sync permission and ownership, it would be great. :-)

Bessonov commented 4 years ago

From my point of view, syncing of user/groups isn't necessary in most cases. But syncing of permissions is a must.

the client/server may be different platforms

True, but MacOS and Linux behaves in similar (or I'm not aware of differences) and windows isn't supported. How do git do that? But maybe (not windows user here) wsl makes it possible right now.

with the right user I want to own the permissions anyway

Please don't interchange permissions with ownership. They are different and has different requirements. chown changes ownership and chmod changes permissions. My use case is to syncing permissions.

granted, I could resolve the id to a user/group name, and then lookup that user/group name on the other side

If this have an use case, then I would propose to introduce a mapping on uid/gid level, like --map-uid=1000:1001 where the first is local user id and the second is remote user id and error for unmapped id's. Same approach for groups.

stephenh commented 4 years ago

windows isn't supported

Yeah, although in theory mirror is fairly platform independent at this point (granted, watchman is beta on windows), so in general I have historically defaulted to less-platform-specific features...

I.e. something like this will be more POSIX-specific API calls instead of just normal java.io.File things that are (generally) auto-supported across all platforms.

My use case is to syncing permissions.

Yeah, makes sense...I wouldn't be against adding a chmod string to each file, that only POSIX platforms would use.

nickodell commented 4 years ago

True, but MacOS and Linux behaves in similar (or I'm not aware of differences) and windows isn't supported. How do git do that? But maybe (not windows user here) wsl makes it possible right now.

Git can sync whether or not a file is marked as executable. If you write a shell script, mark it as executable, and commit it, anyone who clones the repository will also get a script marked as executable. In POSIX terms, Git supports mode 644 and mode 755, and nothing else.