log copy and move errors

This commit is contained in:
Gokcehan 2019-02-28 22:04:57 +03:00
parent 193285a65d
commit 4d2a628550

22
nav.go
View File

@ -576,18 +576,18 @@ func (nav *nav) save(cp bool) error {
} }
func (nav *nav) copyAsync(ui *ui, srcs []string, dstDir string) { func (nav *nav) copyAsync(ui *ui, srcs []string, dstDir string) {
echo := &callExpr{"echo", []string{""}, 1} echo := &callExpr{"echoerr", []string{""}, 1}
_, err := os.Stat(dstDir) _, err := os.Stat(dstDir)
if os.IsNotExist(err) { if os.IsNotExist(err) {
echo.args[0] = fmt.Sprintf("error: %s", err) echo.args[0] = err.Error()
ui.exprChan <- echo ui.exprChan <- echo
return return
} }
total, err := copySize(srcs) total, err := copySize(srcs)
if err != nil { if err != nil {
echo.args[0] = fmt.Sprintf("error: %s", err) echo.args[0] = err.Error()
ui.exprChan <- echo ui.exprChan <- echo
return return
} }
@ -608,24 +608,24 @@ loop:
break loop break loop
} }
errCount++ errCount++
echo.args[0] = fmt.Sprintf("[%d] error: %s", errCount, err) echo.args[0] = fmt.Sprintf("[%d] %s", errCount, err)
ui.exprChan <- echo ui.exprChan <- echo
} }
} }
if err := remote("send load"); err != nil { if err := remote("send load"); err != nil {
errCount++ errCount++
echo.args[0] = fmt.Sprintf("[%d] error: %s", errCount, err) echo.args[0] = fmt.Sprintf("[%d] %s", errCount, err)
ui.exprChan <- echo ui.exprChan <- echo
} }
} }
func (nav *nav) moveAsync(ui *ui, srcs []string, dstDir string) { func (nav *nav) moveAsync(ui *ui, srcs []string, dstDir string) {
echo := &callExpr{"echo", []string{""}, 1} echo := &callExpr{"echoerr", []string{""}, 1}
_, err := os.Stat(dstDir) _, err := os.Stat(dstDir)
if os.IsNotExist(err) { if os.IsNotExist(err) {
echo.args[0] = fmt.Sprintf("error: %s", err) echo.args[0] = err.Error()
ui.exprChan <- echo ui.exprChan <- echo
return return
} }
@ -635,7 +635,7 @@ func (nav *nav) moveAsync(ui *ui, srcs []string, dstDir string) {
srcStat, err := os.Stat(src) srcStat, err := os.Stat(src)
if err != nil { if err != nil {
errCount++ errCount++
echo.args[0] = fmt.Sprintf("[%d] error: %s", errCount, err) echo.args[0] = fmt.Sprintf("[%d] %s", errCount, err)
ui.exprChan <- echo ui.exprChan <- echo
continue continue
} }
@ -645,7 +645,7 @@ func (nav *nav) moveAsync(ui *ui, srcs []string, dstDir string) {
dstStat, err := os.Stat(dst) dstStat, err := os.Stat(dst)
if os.SameFile(srcStat, dstStat) { if os.SameFile(srcStat, dstStat) {
errCount++ errCount++
echo.args[0] = fmt.Sprintf("[%d] error: rename %s %s: source and destination are the same file", errCount, src, dst) echo.args[0] = fmt.Sprintf("[%d] rename %s %s: source and destination are the same file", errCount, src, dst)
ui.exprChan <- echo ui.exprChan <- echo
continue continue
} else if !os.IsNotExist(err) { } else if !os.IsNotExist(err) {
@ -659,14 +659,14 @@ func (nav *nav) moveAsync(ui *ui, srcs []string, dstDir string) {
if err := os.Rename(src, dst); err != nil { if err := os.Rename(src, dst); err != nil {
errCount++ errCount++
echo.args[0] = fmt.Sprintf("[%d] error: %s", errCount, err) echo.args[0] = fmt.Sprintf("[%d] %s", errCount, err)
ui.exprChan <- echo ui.exprChan <- echo
} }
} }
if err := remote("send load"); err != nil { if err := remote("send load"); err != nil {
errCount++ errCount++
echo.args[0] = fmt.Sprintf("[%d] error: %s", errCount, err) echo.args[0] = fmt.Sprintf("[%d] %s", errCount, err)
ui.exprChan <- echo ui.exprChan <- echo
} }
} }