From 04844cf72cb8a3ae2558fa79287653a190cff8a3 Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Tue, 30 Apr 2019 07:44:16 -0700 Subject: [PATCH] check if missing chunks file exists --- src/croc/croc.go | 9 +++++++-- src/utils/utils.go | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/croc/croc.go b/src/croc/croc.go index 1cec896..dc8a648 100644 --- a/src/croc/croc.go +++ b/src/croc/croc.go @@ -517,7 +517,9 @@ func (c *Client) updateState() (err error) { c.FilesToTransfer[c.FilesToTransferCurrentNum].Size, models.TCP_BUFFER_SIZE/2, ) - 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) + } bRequest, _ := json.Marshal(RemoteFileRequest{ CurrentFileChunks: c.CurrentFileChunks, FilesToTransferCurrentNum: c.FilesToTransferCurrentNum, @@ -547,7 +549,10 @@ func (c *Client) updateState() (err error) { progressbar.OptionSetWriter(os.Stderr), progressbar.OptionThrottle(100*time.Millisecond), ) - c.bar.Add(len(c.CurrentFileChunks) * models.TCP_BUFFER_SIZE / 2) + log.Info(c.CurrentFileChunks) + // if len(c.CurrentFileChunks) > 0 { + // c.bar.Add(len(c.CurrentFileChunks) * models.TCP_BUFFER_SIZE / 2) + // } c.TotalSent = 0 for i := 1; i < len(c.Options.RelayPorts); i++ { go c.sendData(i) diff --git a/src/utils/utils.go b/src/utils/utils.go index 36460c4..55e411c 100644 --- a/src/utils/utils.go +++ b/src/utils/utils.go @@ -119,7 +119,7 @@ func ByteCountDecimal(b int64) string { // If the file size is not the same as requested, it returns an empty chunk list (all chunks). func MissingChunks(fname string, fsize int64, chunkSize int) (chunks []int64) { fstat, err := os.Stat(fname) - if fstat.Size() != fsize { + if fstat.Size() != fsize || err != nil { return }