mirror of https://github.com/schollz/croc.git
use xxhash
This commit is contained in:
parent
711690a0f2
commit
aeb30ef187
|
@ -607,6 +607,8 @@ func (c *Client) updateState() (err error) {
|
||||||
if errHash != nil || !bytes.Equal(fileHash, fileInfo.Hash) {
|
if errHash != nil || !bytes.Equal(fileHash, fileInfo.Hash) {
|
||||||
if !bytes.Equal(fileHash, fileInfo.Hash) {
|
if !bytes.Equal(fileHash, fileInfo.Hash) {
|
||||||
log.Debugf("hashes are not equal %x != %x", fileHash, fileInfo.Hash)
|
log.Debugf("hashes are not equal %x != %x", fileHash, fileInfo.Hash)
|
||||||
|
} else {
|
||||||
|
log.Debugf("hashes are equal %x == %x", fileHash, fileInfo.Hash)
|
||||||
}
|
}
|
||||||
finished = false
|
finished = false
|
||||||
c.FilesToTransferCurrentNum = i
|
c.FilesToTransferCurrentNum = i
|
||||||
|
@ -722,12 +724,17 @@ func (c *Client) setBar() {
|
||||||
progressbar.OptionSetWriter(os.Stderr),
|
progressbar.OptionSetWriter(os.Stderr),
|
||||||
progressbar.OptionThrottle(100*time.Millisecond),
|
progressbar.OptionThrottle(100*time.Millisecond),
|
||||||
)
|
)
|
||||||
c.bar.Add(len(c.CurrentFileChunks) * models.TCP_BUFFER_SIZE / 2)
|
byteToDo := int64(len(c.CurrentFileChunks) * models.TCP_BUFFER_SIZE / 2)
|
||||||
|
if byteToDo > 0 {
|
||||||
|
log.Debug(int64(len(c.CurrentFileChunks) * models.TCP_BUFFER_SIZE / 2))
|
||||||
|
log.Debug(c.FilesToTransfer[c.FilesToTransferCurrentNum].Size)
|
||||||
|
bytesDone := c.FilesToTransfer[c.FilesToTransferCurrentNum].Size - int64(len(c.CurrentFileChunks) * models.TCP_BUFFER_SIZE / 2)
|
||||||
|
c.bar.Add64(bytesDone)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) receiveData(i int) {
|
func (c *Client) receiveData(i int) {
|
||||||
for {
|
for {
|
||||||
log.Debug("waiting for data")
|
|
||||||
data, err := c.conn[i+1].Receive()
|
data, err := c.conn[i+1].Receive()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
break
|
break
|
||||||
|
@ -757,7 +764,6 @@ func (c *Client) receiveData(i int) {
|
||||||
c.bar.Add(len(data[8:]))
|
c.bar.Add(len(data[8:]))
|
||||||
c.TotalSent += int64(len(data[8:]))
|
c.TotalSent += int64(len(data[8:]))
|
||||||
c.TotalChunksTransfered++
|
c.TotalChunksTransfered++
|
||||||
log.Debugf("block: %+v", positionInt64)
|
|
||||||
if c.TotalChunksTransfered == len(c.CurrentFileChunks) || c.TotalSent == c.FilesToTransfer[c.FilesToTransferCurrentNum].Size {
|
if c.TotalChunksTransfered == len(c.CurrentFileChunks) || c.TotalSent == c.FilesToTransfer[c.FilesToTransferCurrentNum].Size {
|
||||||
log.Debug("finished receiving!")
|
log.Debug("finished receiving!")
|
||||||
c.CurrentFile.Close()
|
c.CurrentFile.Close()
|
||||||
|
|
|
@ -41,7 +41,7 @@ func GetInput(prompt string) string {
|
||||||
|
|
||||||
// HashFile returns the hash of a file
|
// HashFile returns the hash of a file
|
||||||
func HashFile(fname string) (hash256 []byte, err error) {
|
func HashFile(fname string) (hash256 []byte, err error) {
|
||||||
return IMOHashFile(fname)
|
return XXHashFile(fname)
|
||||||
}
|
}
|
||||||
|
|
||||||
func MD5HashFile(fname string) (hash256 []byte, err error) {
|
func MD5HashFile(fname string) (hash256 []byte, err error) {
|
||||||
|
|
Loading…
Reference in New Issue