mirror of https://github.com/schollz/croc.git
simplify bar add
This commit is contained in:
parent
be7c2ad1fb
commit
87d295f62b
|
@ -518,11 +518,8 @@ func (c *Client) updateState() (err error) {
|
||||||
progressbar.OptionSetWriter(os.Stderr),
|
progressbar.OptionSetWriter(os.Stderr),
|
||||||
progressbar.OptionThrottle(100*time.Millisecond),
|
progressbar.OptionThrottle(100*time.Millisecond),
|
||||||
)
|
)
|
||||||
c.TotalSent = 0
|
|
||||||
|
|
||||||
if len(c.CurrentFileChunks) > 0 {
|
|
||||||
c.bar.Add(len(c.CurrentFileChunks) * models.TCP_BUFFER_SIZE / 2)
|
c.bar.Add(len(c.CurrentFileChunks) * models.TCP_BUFFER_SIZE / 2)
|
||||||
}
|
c.TotalSent = 0
|
||||||
bRequest, _ := json.Marshal(RemoteFileRequest{
|
bRequest, _ := json.Marshal(RemoteFileRequest{
|
||||||
CurrentFileChunks: c.CurrentFileChunks,
|
CurrentFileChunks: c.CurrentFileChunks,
|
||||||
FilesToTransferCurrentNum: c.FilesToTransferCurrentNum,
|
FilesToTransferCurrentNum: c.FilesToTransferCurrentNum,
|
||||||
|
@ -552,10 +549,7 @@ func (c *Client) updateState() (err error) {
|
||||||
progressbar.OptionSetWriter(os.Stderr),
|
progressbar.OptionSetWriter(os.Stderr),
|
||||||
progressbar.OptionThrottle(100*time.Millisecond),
|
progressbar.OptionThrottle(100*time.Millisecond),
|
||||||
)
|
)
|
||||||
log.Info(c.CurrentFileChunks)
|
c.bar.Add(len(c.CurrentFileChunks) * models.TCP_BUFFER_SIZE / 2)
|
||||||
// if len(c.CurrentFileChunks) > 0 {
|
|
||||||
// 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)
|
||||||
|
@ -655,7 +649,7 @@ func (c *Client) sendData(i int) {
|
||||||
}
|
}
|
||||||
c.mutex.Unlock()
|
c.mutex.Unlock()
|
||||||
if usableChunk {
|
if usableChunk {
|
||||||
log.Debugf("sending chunk %d", pos)
|
// log.Debugf("sending chunk %d", pos)
|
||||||
posByte := make([]byte, 8)
|
posByte := make([]byte, 8)
|
||||||
binary.LittleEndian.PutUint64(posByte, pos)
|
binary.LittleEndian.PutUint64(posByte, pos)
|
||||||
|
|
||||||
|
@ -676,7 +670,7 @@ func (c *Client) sendData(i int) {
|
||||||
c.TotalSent += int64(n)
|
c.TotalSent += int64(n)
|
||||||
// time.Sleep(100 * time.Millisecond)
|
// time.Sleep(100 * time.Millisecond)
|
||||||
} else {
|
} else {
|
||||||
log.Debugf("skipping chunk %d", pos)
|
// log.Debugf("skipping chunk %d", pos)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue