textmate / rmate

Edit files from an ssh session in TextMate
http://blog.macromates.com/2011/mate-and-rmate/
516 stars 81 forks source link

Cannot save remote files that I do not own. #11

Closed sellmerfud closed 11 years ago

sellmerfud commented 11 years ago

When I edit a file that I do not own on the remote system, but I do have write permission (group or world), the save operation cannot complete.

This is due to to the rmate script creating a temporary file and then trying to chown the file with the user:group of the original file. Since I do not own the file, this fails and the write operation aborts.

sorbits commented 11 years ago

We don’t write directly to the original file since we want to do an atomic update, especially considering we get the file data over the network (which isn’t 100% reliable).

Suggestions (or patches) for how to improve the code though are more than welcome.

On Feb 27, 2013, at 10:01 PM, Curt Sellmer notifications@github.com wrote:

When I edit a file that I do not own on the remote system, but I do have write permission (group or world), the save operation cannot complete.

This is due to to the rmate script creating a temporary file and then trying to chown the file with the user:group of the original file. Since I do not own the file, this fails and the write operation aborts.

— Reply to this email directly or view it on GitHub.

sellmerfud commented 11 years ago

Not a big deal, now that I know the limitation. There's no indication that it fails so it took a bit of time to discover it.

The only alternative that I can think of is rather than hard link the file then copy the temp file over the original, you could make a copy of the original, then write directly over the original. Then if there were no errors, delete the backup copy. This would be slower for large files, but it would preserve the files attributes. Of course the ownership of the backup copy would be set to your user and default group.