Fix copy progress bug when copying files with 0 size (#2130)
* Fix copy progress when copying files with 0 size * typo * Update `CHANGELOG.md`
This commit is contained in:
1 parent
f26b30be18
commit
d079cc8719
3 files changed
+15
-9
No files matched your search
@@ -29,6 +29,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||
|
||||
- Error messages are now cleared after running interactive commands such as `invert`/`unselect`/`tag-toggle` (#2117).
|
||||
- The menu is now drawn over sixel images instead of being hidden behind it if they overlap (#2122).
|
||||
- A bug which prevents the user from quitting when copying files with a size of 0 has been fixed (#2130).
|
||||
|
||||
## [r37](https://github.com/gokcehan/lf/releases/tag/r37)
|
||||
|
||||
|
||||
@@ -340,8 +340,8 @@ func (app *app) loop() {
|
||||
log.Print("bye!")
|
||||
|
||||
return
|
||||
case <-app.nav.copyJobsChan:
|
||||
app.nav.copyJobs += 1
|
||||
case n := <-app.nav.copyJobsChan:
|
||||
app.nav.copyJobs += n
|
||||
app.ui.draw(app.nav)
|
||||
case n := <-app.nav.copyBytesChan:
|
||||
app.nav.copyBytes += n
|
||||
|
||||
@@ -446,7 +446,7 @@ type nav struct {
|
||||
deleteCount int
|
||||
deleteTotal int
|
||||
deleteUpdate int
|
||||
copyJobsChan chan struct{}
|
||||
copyJobsChan chan int
|
||||
copyBytesChan chan int64
|
||||
copyTotalChan chan int64
|
||||
moveCountChan chan int
|
||||
@@ -582,7 +582,7 @@ func (nav *nav) getDirs(wd string) {
|
||||
|
||||
func newNav(height int) *nav {
|
||||
nav := &nav{
|
||||
copyJobsChan: make(chan struct{}, 1024),
|
||||
copyJobsChan: make(chan int, 1024),
|
||||
copyBytesChan: make(chan int64, 1024),
|
||||
copyTotalChan: make(chan int64, 1024),
|
||||
moveCountChan: make(chan int, 1024),
|
||||
@@ -1224,15 +1224,15 @@ func (nav *nav) copyAsync(app *app, srcs []string, dstDir string) {
|
||||
return
|
||||
}
|
||||
|
||||
// indicate that a copy operation is in progress
|
||||
// using the total bytes to determine this instead will mean that it is
|
||||
// possible for copySize to take a while, but not be reflected in the UI
|
||||
// until it has finished
|
||||
nav.copyJobsChan <- struct{}{}
|
||||
// Indicate that a copy operation is in progress. Using the total bytes to
|
||||
// determine this instead will mean that it is possible for copySize to take
|
||||
// a while, but not be reflected in the UI until it has finished.
|
||||
nav.copyJobsChan <- 1
|
||||
|
||||
total, err := copySize(srcs)
|
||||
if err != nil {
|
||||
sendErr("%v", err)
|
||||
nav.copyJobsChan <- -1
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1253,6 +1253,7 @@ loop:
|
||||
}
|
||||
}
|
||||
|
||||
nav.copyJobsChan <- -1
|
||||
nav.copyTotalChan <- -total
|
||||
|
||||
if gSingleMode {
|
||||
@@ -1318,9 +1319,12 @@ func (nav *nav) moveAsync(app *app, srcs []string, dstDir string) {
|
||||
|
||||
if err := os.Rename(src, dst); err != nil {
|
||||
if errCrossDevice(err) {
|
||||
nav.copyJobsChan <- 1
|
||||
|
||||
total, err := copySize([]string{src})
|
||||
if err != nil {
|
||||
sendErr("%v", err)
|
||||
nav.copyJobsChan <- -1
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -1342,6 +1346,7 @@ func (nav *nav) moveAsync(app *app, srcs []string, dstDir string) {
|
||||
}
|
||||
}
|
||||
|
||||
nav.copyJobsChan <- -1
|
||||
nav.copyTotalChan <- -total
|
||||
|
||||
if errCount == oldCount {
|
||||
|
||||
Reference in new issue
Block a user