Update core

This commit is contained in:
Kleissner
2022-02-22 14:04:04 +01:00
parent fe65508649
commit eff8327a74
3 changed files with 11 additions and 12 deletions

View File

@@ -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
}

4
go.mod
View File

@@ -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
)

8
go.sum
View File

@@ -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=