Ticket #3163 (new enhancement)

Opened 6 years ago

Last modified 6 years ago

Several improvements in editor saving behavior

Reported by: CyberShadow Owned by:
Priority: minor Milestone: Future Releases
Component: mcedit Version: master
Keywords: Cc: egmont@…
Blocked By: Blocking:
Branch state: no branch Votes for changeset:

Description

I have created a pull request on GitHub? a week ago, kindly review it:
https://github.com/MidnightCommander/mc/pull/32

Change History

comment:1 follow-up: ↓ 2 Changed 6 years ago by egmont

Just a random guy's opinion:

Invoking external sudo (a file manager calling an external command to copy) looks ugly and fragile to me. What if sudo is configured not to work for that user? What if an error occurs during execution, how will it be propagated to the user? (Would you read back the file to verify that it was copied successfully?) Could you be sure that permissions, symlinks, hardlinks, whatever are maintained exactly as if mcedit saved the file? How would you handle creating a backup according to mcedit's preference?

In my opinion, it would be cleaner if mcedit warned you that the file is not writable when you opened the file, or when attempted to first modify it. Or if it set the buffer read-only. You could immediately quit and go for "sudo mcedit" or similar.

comment:2 in reply to: ↑ 1 Changed 6 years ago by andrew_b

Replying to egmont:

In my opinion, it would be cleaner if mcedit warned you that the file is not writable when you opened the file, or when attempted to first modify it.

#1688

Or if it set the buffer read-only.

#83

comment:3 Changed 6 years ago by egmont

  • Cc egmont@… added

One more problematic case occurred to me with sudo. When you can't write a file, it's not necessarily because it's owned by root. It can be that the file belongs to the user but has no write permissions. It could be that the file belongs to another (non-root) user, whom should we sudo then (and if we sudo to root, how would we set the file's owner/group)? It could be that the file belongs to someone else over a network filesystem, in that case sudo doesn't help either. I'm not saying it's impossible, I'm just saying it's probably terribly complicated and error prone and probably the wrong approach the address the initial problem.

Last edited 6 years ago by egmont (previous) (diff)

comment:4 Changed 6 years ago by egmont

That being said, it's just one of the commits in the pull request - the other ones look promising based on their changelog entry.

Note: See TracTickets for help on using tickets.