mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 21:30:16 +02:00
simplify ui
This commit is contained in:
parent
3bf7635f33
commit
c8fdd4726a
1 changed files with 22 additions and 26 deletions
|
@ -506,19 +506,7 @@ func (c *Client) updateState() (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// setup the progressbar
|
// setup the progressbar
|
||||||
c.bar = progressbar.NewOptions64(
|
c.setBar()
|
||||||
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.TotalSent = 0
|
c.TotalSent = 0
|
||||||
bRequest, _ := json.Marshal(RemoteFileRequest{
|
bRequest, _ := json.Marshal(RemoteFileRequest{
|
||||||
CurrentFileChunks: c.CurrentFileChunks,
|
CurrentFileChunks: c.CurrentFileChunks,
|
||||||
|
@ -537,19 +525,7 @@ func (c *Client) updateState() (err error) {
|
||||||
log.Debug("start sending data!")
|
log.Debug("start sending data!")
|
||||||
c.Step4FileTransfer = true
|
c.Step4FileTransfer = true
|
||||||
// setup the progressbar
|
// setup the progressbar
|
||||||
c.bar = progressbar.NewOptions64(
|
c.setBar()
|
||||||
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.TotalSent = 0
|
c.TotalSent = 0
|
||||||
for i := 1; i < len(c.Options.RelayPorts); i++ {
|
for i := 1; i < len(c.Options.RelayPorts); i++ {
|
||||||
go c.sendData(i)
|
go c.sendData(i)
|
||||||
|
@ -558,6 +534,26 @@ func (c *Client) updateState() (err error) {
|
||||||
return
|
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) {
|
func (c *Client) receiveData(i int) {
|
||||||
for {
|
for {
|
||||||
log.Debug("waiting for data")
|
log.Debug("waiting for data")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue