actions: saveas: Fix crash at access without permission#3082
actions: saveas: Fix crash at access without permission#3082zyedidia merged 1 commit intomicro-editor:masterfrom
Conversation
|
Hello
if os.IsNotExist(err) || os.IsPermission(err) {
if os.IsPermission(err) {
WriteLog(err.Error())
}Does
The
What do you mean? How would it look?
Do you mean separate function for file loading that will silently load file if can or prompt user for permissions? |
The load/check needs to be done with more privileges, otherwise we can't test. Afterwards the possible YN prompt for overwrite can be displayed. |
dd0ea99 to
a4ca078
Compare
|
Hmmm.... We have two different "permission errors". I messed up them and thought that we have only one
I experimented with 1 kind so I didn't notice any changes with adding I understand now, thank you! |
In the moment
os.Stat()fails due to not existing permissionfileinfo.Name()will be access, which we need to prevent. In that case we can't be sure, if the file exists or not anyway. Missing privileges should lead to a call ofsaveBufToFilesince this will take care of extending privileges (e.g. by invokingsudo).Currently the behavior ignores existing files which can't be accessed due to missing permissions. They will be overwritten in the moment
sudois invoked without any further check if the user wants to overwrite possible existing ones.On
microstart with such a files as parameter we will receive the complaint:So maybe we need a more plausible but more complex solution to 1. stat with more privileges and 2. ask to load/read the file with more privileges.
Fixes #3080