Break transfer loops after refreshing progress bar

This commit is contained in:
Elara 2021-08-27 09:01:46 -07:00
parent 44607ba9e2
commit 419b2f5a79
2 changed files with 8 additions and 8 deletions

View File

@ -95,14 +95,14 @@ var upgradeCmd = &cobra.Command{
if err != nil {
log.Fatal().Err(err).Msg("Error decoding response data")
}
// If transfer finished, break
if event.Received == event.Total {
break
}
// Set total bytes in progress bar
bar.SetTotal(event.Total)
// Set amount of bytes received in progress bar
bar.SetCurrent(event.Received)
// If transfer finished, break
if event.Received == event.Total {
break
}
}
// Finish progress bar
bar.Finish()

View File

@ -164,10 +164,6 @@ func upgradeTab(parent fyne.Window) *fyne.Container {
guiErr(err, "Error decoding response value", false, parent)
return
}
// If transfer finished, break
if event.Received == event.Total {
break
}
// Set label text to received / total B
progressLbl.SetText(fmt.Sprintf("%d / %d B", event.Received, event.Total))
// Set progress bar values
@ -175,6 +171,10 @@ func upgradeTab(parent fyne.Window) *fyne.Container {
progressBar.Value = float64(event.Received)
// Refresh progress bar
progressBar.Refresh()
// If transfer finished, break
if event.Received == event.Total {
break
}
}
})