parent
f76bf30f65
commit
d5f989f373
17
app.go
17
app.go
@ -179,7 +179,7 @@ func (app *app) loop() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if app.nav.deleting {
|
if app.nav.deleteTotal > 0 {
|
||||||
app.ui.echoerr("quit: delete operation in progress")
|
app.ui.echoerr("quit: delete operation in progress")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -237,6 +237,21 @@ func (app *app) loop() {
|
|||||||
app.nav.moveUpdate = 0
|
app.nav.moveUpdate = 0
|
||||||
}
|
}
|
||||||
app.ui.draw(app.nav)
|
app.ui.draw(app.nav)
|
||||||
|
case n := <-app.nav.deleteCountChan:
|
||||||
|
app.nav.deleteCount += n
|
||||||
|
if app.nav.deleteUpdate++; app.nav.deleteUpdate >= 1000 {
|
||||||
|
app.nav.deleteUpdate = 0
|
||||||
|
app.ui.draw(app.nav)
|
||||||
|
}
|
||||||
|
case n := <-app.nav.deleteTotalChan:
|
||||||
|
app.nav.deleteTotal += n
|
||||||
|
if n < 0 {
|
||||||
|
app.nav.deleteCount += n
|
||||||
|
}
|
||||||
|
if app.nav.deleteTotal == 0 {
|
||||||
|
app.nav.deleteUpdate = 0
|
||||||
|
}
|
||||||
|
app.ui.draw(app.nav)
|
||||||
case d := <-app.nav.dirChan:
|
case d := <-app.nav.dirChan:
|
||||||
prev, ok := app.nav.dirCache[d.path]
|
prev, ok := app.nav.dirCache[d.path]
|
||||||
if ok {
|
if ok {
|
||||||
|
24
nav.go
24
nav.go
@ -248,11 +248,15 @@ type nav struct {
|
|||||||
moveCount int
|
moveCount int
|
||||||
moveTotal int
|
moveTotal int
|
||||||
moveUpdate int
|
moveUpdate int
|
||||||
deleting bool
|
deleteCount int
|
||||||
|
deleteTotal int
|
||||||
|
deleteUpdate int
|
||||||
copyBytesChan chan int64
|
copyBytesChan chan int64
|
||||||
copyTotalChan chan int64
|
copyTotalChan chan int64
|
||||||
moveCountChan chan int
|
moveCountChan chan int
|
||||||
moveTotalChan chan int
|
moveTotalChan chan int
|
||||||
|
deleteCountChan chan int
|
||||||
|
deleteTotalChan chan int
|
||||||
dirChan chan *dir
|
dirChan chan *dir
|
||||||
regChan chan *reg
|
regChan chan *reg
|
||||||
dirCache map[string]*dir
|
dirCache map[string]*dir
|
||||||
@ -340,6 +344,8 @@ func newNav(height int) *nav {
|
|||||||
copyTotalChan: make(chan int64, 1024),
|
copyTotalChan: make(chan int64, 1024),
|
||||||
moveCountChan: make(chan int, 1024),
|
moveCountChan: make(chan int, 1024),
|
||||||
moveTotalChan: make(chan int, 1024),
|
moveTotalChan: make(chan int, 1024),
|
||||||
|
deleteCountChan: make(chan int, 1024),
|
||||||
|
deleteTotalChan: make(chan int, 1024),
|
||||||
dirChan: make(chan *dir),
|
dirChan: make(chan *dir),
|
||||||
regChan: make(chan *reg),
|
regChan: make(chan *reg),
|
||||||
dirCache: make(map[string]*dir),
|
dirCache: make(map[string]*dir),
|
||||||
@ -785,21 +791,27 @@ func (nav *nav) del(ui *ui) error {
|
|||||||
go func() {
|
go func() {
|
||||||
echo := &callExpr{"echoerr", []string{""}, 1}
|
echo := &callExpr{"echoerr", []string{""}, 1}
|
||||||
errCount := 0
|
errCount := 0
|
||||||
nav.deleting = true
|
|
||||||
|
nav.deleteTotalChan <- len(list)
|
||||||
|
|
||||||
for _, path := range list {
|
for _, path := range list {
|
||||||
|
nav.deleteCountChan <- 1
|
||||||
|
|
||||||
if err := os.RemoveAll(path); err != nil {
|
if err := os.RemoveAll(path); err != nil {
|
||||||
errCount++
|
errCount++
|
||||||
echo.args[0] = fmt.Sprintf("[%d] %s", errCount, err)
|
echo.args[0] = fmt.Sprintf("[%d] %s", errCount, err)
|
||||||
ui.exprChan <- echo
|
ui.exprChan <- echo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nav.deleting = false
|
|
||||||
}()
|
|
||||||
|
|
||||||
if err := remote("send sync"); err != nil {
|
nav.deleteTotalChan <- -len(list)
|
||||||
return fmt.Errorf("delete: %s", err)
|
|
||||||
|
if err := remote("send load"); err != nil {
|
||||||
|
errCount++
|
||||||
|
echo.args[0] = fmt.Sprintf("[%d] %s", errCount, err)
|
||||||
|
ui.exprChan <- echo
|
||||||
}
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
4
ui.go
4
ui.go
@ -616,6 +616,10 @@ func (ui *ui) drawStatLine(nav *nav) {
|
|||||||
progress += fmt.Sprintf(" [%d/%d]", nav.moveCount, nav.moveTotal)
|
progress += fmt.Sprintf(" [%d/%d]", nav.moveCount, nav.moveTotal)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if nav.deleteTotal > 0 {
|
||||||
|
progress += fmt.Sprintf(" [%d/%d]", nav.deleteCount, nav.deleteTotal)
|
||||||
|
}
|
||||||
|
|
||||||
ruler := fmt.Sprintf("%s%s %d/%d", acc, progress, ind, tot)
|
ruler := fmt.Sprintf("%s%s %d/%d", acc, progress, ind, tot)
|
||||||
|
|
||||||
ui.msgWin.printRight(0, fg, bg, ruler)
|
ui.msgWin.printRight(0, fg, bg, ruler)
|
||||||
|
Loading…
Reference in New Issue
Block a user