diff --git a/File Transfer.go b/File Transfer.go index ea1a0b9..336600b 100644 --- a/File Transfer.go +++ b/File Transfer.go @@ -24,12 +24,11 @@ import ( // Note: The file MUST be stored locally, otherwise this function fails. func transferCompareFile(peer *core.PeerInfo, fileHash []byte, output io.Writer) { // check if the file exists locally - _, fileInfo, status, _ := peer.Backend.UserWarehouse.FileExists(fileHash) + _, fileSizeLocal, status, _ := peer.Backend.UserWarehouse.FileExists(fileHash) if status != warehouse.StatusOK { fmt.Fprintf(output, "File does not exist in local warehouse: %s\n", hex.EncodeToString(fileHash)) return } - expectedSize := fileInfo.Size() // peer must be connected if !peer.IsConnectionActive() { @@ -55,15 +54,15 @@ func transferCompareFile(peer *core.PeerInfo, fileHash []byte, output io.Writer) return } - if fileSize != uint64(expectedSize) { - fmt.Fprintf(output, "Error expected local file size %d mismatch with remote file size %d\n", expectedSize, fileSize) + if fileSize != fileSizeLocal { + fmt.Fprintf(output, "Error expected local file size %d mismatch with remote file size %d\n", fileSizeLocal, fileSize) return } else if fileSize != transferSize { fmt.Fprintf(output, "Error remote peer only offering %d of total file size %d\n", transferSize, fileSize) return } - fmt.Fprintf(output, "3. Matching transfer size %d and file size %d\n", transferSize, expectedSize) + fmt.Fprintf(output, "3. Matching transfer size %d and file size %d\n", transferSize, fileSizeLocal) // Previous: Loop in explicitly 512 bytes (which is the same buffer as io.Copy apparently) and compare with what is expected. // Now use 4 KB buffer. @@ -136,7 +135,7 @@ func transferCompareFile(peer *core.PeerInfo, fileHash []byte, output io.Writer) fmt.Fprintf(output, "Transfer took %s. Speed is %.2f KB/s\n", time.Since(timeStart).String(), speed) - if totalRead != int(expectedSize) { + if totalRead != int(fileSizeLocal) { fmt.Fprintf(output, "Error transferred data %d mismatch with reported file size %d\n", totalRead, fileSize) return } diff --git a/go.mod b/go.mod index 06f071c..1231f6e 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/PeernetOfficial/Cmd go 1.16 require ( - github.com/PeernetOfficial/core v0.0.0-20220205200523-b76601e11c56 + github.com/PeernetOfficial/core v0.0.0-20220221213520-ee22bf641a08 github.com/google/uuid v1.3.0 - github.com/gorilla/websocket v1.4.3-0.20210424162022-e8629af678b7 + github.com/gorilla/websocket v1.5.0 ) diff --git a/go.sum b/go.sum index 7e0cdb8..59d193c 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ github.com/IncSW/geoip2 v0.1.2 h1:v7iAyDiNZjHES45P1JPM3SMvkw0VNeJtz0XSVxkRwOY= github.com/IncSW/geoip2 v0.1.2/go.mod h1:adcasR40vXiUBjtzdaTTKL/6wSf+fgO4M8Gve/XzPUk= -github.com/PeernetOfficial/core v0.0.0-20220205200523-b76601e11c56 h1:X8kdn1Vv9KJh1ceLi5+5iZtQKil61NIQpUPvbmQB+JI= -github.com/PeernetOfficial/core v0.0.0-20220205200523-b76601e11c56/go.mod h1:nP1xfYJ0CTSlLp6GfMOMxPnw7NmzwoGeZiFQ4kfhd0o= +github.com/PeernetOfficial/core v0.0.0-20220221213520-ee22bf641a08 h1:VCpcEotp9hkN30nmrnhqqMvihf+3FyH21GHpVvCR5do= +github.com/PeernetOfficial/core v0.0.0-20220221213520-ee22bf641a08/go.mod h1:nP1xfYJ0CTSlLp6GfMOMxPnw7NmzwoGeZiFQ4kfhd0o= github.com/akrylysov/pogreb v0.10.1 h1:FqlR8VR7uCbJdfUob916tPM+idpKgeESDXOA1K0DK4w= github.com/akrylysov/pogreb v0.10.1/go.mod h1:pNs6QmpQ1UlTJKDezuRWmaqkgUE2TuU0YTWyqJZ7+lI= github.com/enfipy/locker v1.1.0 h1:2zVJ0ky7cS1Vjs0x6OQWFiT2dSEiHrI5/O2KCz1fgGc= @@ -11,8 +11,8 @@ github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/gorilla/websocket v1.4.3-0.20210424162022-e8629af678b7 h1:L89uC9ATI61/V2eNgZYtQHyjjyjEplemB+aky4HdyzQ= -github.com/gorilla/websocket v1.4.3-0.20210424162022-e8629af678b7/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= +github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= golang.org/x/crypto v0.0.0-20220131195533-30dcbda58838 h1:71vQrMauZZhcTVK6KdYM+rklehEEwb3E+ZhaE5jrPrE=