This commit is contained in:
Kovid Goyal
2023-07-25 09:52:11 +05:30
parent 5881041fcd
commit aad1ab3fd9
2 changed files with 8 additions and 15 deletions

View File

@@ -431,15 +431,6 @@ func (self *handler) abort_with_error(err error, delay ...time.Duration) {
self.print_err(err) self.print_err(err)
} }
self.lp.Println(`Waiting to ensure terminal cancels transfer, will quit in a few seconds`) self.lp.Println(`Waiting to ensure terminal cancels transfer, will quit in a few seconds`)
self.abort_transfer(delay...)
}
func (self *handler) do_error_quit(loop.IdType) error {
self.lp.Quit(1)
return nil
}
func (self *handler) abort_transfer(delay ...time.Duration) {
var d time.Duration = 5 * time.Second var d time.Duration = 5 * time.Second
if len(delay) > 0 { if len(delay) > 0 {
d = delay[0] d = delay[0]
@@ -449,6 +440,11 @@ func (self *handler) abort_transfer(delay ...time.Duration) {
self.lp.AddTimer(d, false, self.do_error_quit) self.lp.AddTimer(d, false, self.do_error_quit)
} }
func (self *handler) do_error_quit(loop.IdType) error {
self.lp.Quit(1)
return nil
}
func (self *manager) finalize_transfer() (err error) { func (self *manager) finalize_transfer() (err error) {
self.transfer_done = true self.transfer_done = true
rid_map := make(map[string]*remote_file) rid_map := make(map[string]*remote_file)
@@ -720,7 +716,7 @@ func (self *handler) print_check_paths() {
self.lp.QueueWriteString(" ") self.lp.QueueWriteString(" ")
lpath := df.expanded_local_path lpath := df.expanded_local_path
if lexists(lpath) { if lexists(lpath) {
lpath = self.ctx.Prettify(fmt.Sprintf(":red:`%s` ", lpath)) lpath = self.ctx.Prettify(self.ctx.BrightRed(lpath) + " ")
} }
self.lp.Println(df.display_name, " → ", lpath) self.lp.Println(df.display_name, " → ", lpath)
} }
@@ -972,8 +968,7 @@ func (self *handler) on_text(text string, from_key_event, in_bracketed_paste boo
self.start_transfer() self.start_transfer()
return nil return nil
case "n": case "n":
self.abort_transfer() self.abort_with_error(fmt.Errorf(`Canceled by user`))
self.lp.Println(`Waiting for cancel acknowledgement from terminal`)
return nil return nil
} }
self.print_continue_msg() self.print_continue_msg()
@@ -987,8 +982,7 @@ func (self *handler) on_key_event(ev *loop.KeyEvent) error {
if ev.MatchesPressOrRepeat("esc") { if ev.MatchesPressOrRepeat("esc") {
ev.Handled = true ev.Handled = true
if self.check_paths_printed && !self.transmit_started { if self.check_paths_printed && !self.transmit_started {
self.abort_transfer() self.abort_with_error(fmt.Errorf(`Canceled by user`))
self.lp.Println(`Waiting for cancel acknowledgement from terminal`)
} else { } else {
self.on_interrupt() self.on_interrupt()
} }

View File

@@ -8,7 +8,6 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"testing" "testing"
"time"
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
) )