-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Restore original files permissions #922
Conversation
@@ -41,7 +41,11 @@ function! go#asmfmt#Format() | |||
|
|||
" Replace the current file with the temp file; then reload the buffer. | |||
let old_fileformat = &fileformat | |||
" save old file permissions | |||
let original_fperm = getfperm(expand('%')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the doc this also returns -
if the user does not have the given permission. We should test if the variable is -
below before we set it to prevent unwanted errors.
Thanks @joegrasse. If you add the check in |
Actually I believe we don't want the check for |
The problem is that it should not set the permissions when |
I sorry, I guess I am not following you. Are you thinking there is the case where it would return only |
Passing "-" back into
However, in the reported bug, there are two separate files: the original one with the intended permissions and a temp file that has different (wrong) permissions due to the user's umask. When the temp file is moved over the original file, the temp file's permissions overwrite the original, intended permissions. This could lead to problems such as a world-writable file suddenly becoming read-only to everyone but the current user (or worse, it could happen the other way around). This PR reapplies the permissions from the original file to the temp file exactly as they were. When the temp file is moved into place, it will have the same permissions as it did before calling |
Do the last couple of comments clear your questions up for you, or do you still have concerns? |
Thanks @joegrasse |
This fixes #921.