simplify ui

This commit is contained in:
Zack Scholl 2019-04-30 09:24:32 -07:00
parent 3bf7635f33
commit c8fdd4726a
1 changed files with 22 additions and 26 deletions

View File

@ -506,19 +506,7 @@ func (c *Client) updateState() (err error) {
}
// setup the progressbar
c.bar = progressbar.NewOptions64(
c.FilesToTransfer[c.FilesToTransferCurrentNum].Size,
progressbar.OptionOnCompletion(func() {
fmt.Fprintf(os.Stderr, " ✔️\n")
}),
progressbar.OptionSetWidth(8),
progressbar.OptionSetDescription(fmt.Sprintf("%28s", c.FilesToTransfer[c.FilesToTransferCurrentNum].Name)),
progressbar.OptionSetRenderBlankState(true),
progressbar.OptionSetBytes64(c.FilesToTransfer[c.FilesToTransferCurrentNum].Size),
progressbar.OptionSetWriter(os.Stderr),
progressbar.OptionThrottle(100*time.Millisecond),
)
c.bar.Add(len(c.CurrentFileChunks) * models.TCP_BUFFER_SIZE / 2)
c.setBar()
c.TotalSent = 0
bRequest, _ := json.Marshal(RemoteFileRequest{
CurrentFileChunks: c.CurrentFileChunks,
@ -537,19 +525,7 @@ func (c *Client) updateState() (err error) {
log.Debug("start sending data!")
c.Step4FileTransfer = true
// setup the progressbar
c.bar = progressbar.NewOptions64(
c.FilesToTransfer[c.FilesToTransferCurrentNum].Size,
progressbar.OptionOnCompletion(func() {
fmt.Fprintf(os.Stderr, " ✔️\n")
}),
progressbar.OptionSetWidth(8),
progressbar.OptionSetDescription(fmt.Sprintf("%28s", c.FilesToTransfer[c.FilesToTransferCurrentNum].Name)),
progressbar.OptionSetRenderBlankState(true),
progressbar.OptionSetBytes64(c.FilesToTransfer[c.FilesToTransferCurrentNum].Size),
progressbar.OptionSetWriter(os.Stderr),
progressbar.OptionThrottle(100*time.Millisecond),
)
c.bar.Add(len(c.CurrentFileChunks) * models.TCP_BUFFER_SIZE / 2)
c.setBar()
c.TotalSent = 0
for i := 1; i < len(c.Options.RelayPorts); i++ {
go c.sendData(i)
@ -558,6 +534,26 @@ func (c *Client) updateState() (err error) {
return
}
func (c *Client) setBar() {
description := fmt.Sprintf("%28s", c.FilesToTransfer[c.FilesToTransferCurrentNum].Name)
if len(c.FilesToTransfer) == 1 {
description = c.FilesToTransfer[c.FilesToTransferCurrentNum].Name
}
c.bar = progressbar.NewOptions64(
c.FilesToTransfer[c.FilesToTransferCurrentNum].Size,
progressbar.OptionOnCompletion(func() {
fmt.Fprintf(os.Stderr, " ✔️\n")
}),
progressbar.OptionSetWidth(8),
progressbar.OptionSetDescription(description),
progressbar.OptionSetRenderBlankState(true),
progressbar.OptionSetBytes64(c.FilesToTransfer[c.FilesToTransferCurrentNum].Size),
progressbar.OptionSetWriter(os.Stderr),
progressbar.OptionThrottle(100*time.Millisecond),
)
c.bar.Add(len(c.CurrentFileChunks) * models.TCP_BUFFER_SIZE / 2)
}
func (c *Client) receiveData(i int) {
for {
log.Debug("waiting for data")