actions: saveas: Fix crash at access without permission (#3082)
This commit is contained in:
parent
d8e9d61a95
commit
2d82362a66
1 changed files with 13 additions and 12 deletions
|
@ -793,25 +793,26 @@ func (h *BufPane) SaveAsCB(action string, callback func()) bool {
|
||||||
filename := strings.Join(args, " ")
|
filename := strings.Join(args, " ")
|
||||||
fileinfo, err := os.Stat(filename)
|
fileinfo, err := os.Stat(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if os.IsNotExist(err) {
|
if errors.Is(err, fs.ErrNotExist) || errors.Is(err, fs.ErrPermission) {
|
||||||
noPrompt := h.saveBufToFile(filename, action, callback)
|
noPrompt := h.saveBufToFile(filename, action, callback)
|
||||||
if noPrompt {
|
if noPrompt {
|
||||||
h.completeAction(action)
|
h.completeAction(action)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
InfoBar.YNPrompt(
|
InfoBar.YNPrompt(
|
||||||
fmt.Sprintf("the file %s already exists in the directory, would you like to overwrite? Y/n", fileinfo.Name()),
|
fmt.Sprintf("The file %s already exists in the directory, would you like to overwrite? Y/n", fileinfo.Name()),
|
||||||
func(yes, canceled bool) {
|
func(yes, canceled bool) {
|
||||||
if yes && !canceled {
|
if yes && !canceled {
|
||||||
noPrompt := h.saveBufToFile(filename, action, callback)
|
noPrompt := h.saveBufToFile(filename, action, callback)
|
||||||
if noPrompt {
|
if noPrompt {
|
||||||
h.completeAction(action)
|
h.completeAction(action)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
)
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Reference in a new issue