Skip to content

Commit

Permalink
actions: saveas: Fix crash at access without permission
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeKar committed Dec 10, 2023
1 parent d8e9d61 commit a4ca078
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions internal/action/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -793,25 +793,26 @@ func (h *BufPane) SaveAsCB(action string, callback func()) bool {
filename := strings.Join(args, " ")
fileinfo, err := os.Stat(filename)
if err != nil {
if os.IsNotExist(err) {
if errors.Is(err, fs.ErrNotExist) || errors.Is(err, fs.ErrPermission) {
noPrompt := h.saveBufToFile(filename, action, callback)
if noPrompt {
h.completeAction(action)
return
}
}
}
InfoBar.YNPrompt(
fmt.Sprintf("the file %s already exists in the directory, would you like to overwrite? Y/n", fileinfo.Name()),
func(yes, canceled bool) {
if yes && !canceled {
noPrompt := h.saveBufToFile(filename, action, callback)
if noPrompt {
h.completeAction(action)
} else {
InfoBar.YNPrompt(
fmt.Sprintf("The file %s already exists in the directory, would you like to overwrite? Y/n", fileinfo.Name()),
func(yes, canceled bool) {
if yes && !canceled {
noPrompt := h.saveBufToFile(filename, action, callback)
if noPrompt {
h.completeAction(action)
}
}
}
},
)
},
)
}
}
})
return false
Expand Down

0 comments on commit a4ca078

Please sign in to comment.