Use v2 of XDR package (auto generated)
This commit is contained in:
@@ -7,8 +7,6 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"github.com/calmh/xdr"
|
||||
"github.com/syncthing/syncthing/lib/protocol"
|
||||
)
|
||||
@@ -18,32 +16,32 @@ type FileInfoTruncated struct {
|
||||
}
|
||||
|
||||
func (o *FileInfoTruncated) UnmarshalXDR(bs []byte) error {
|
||||
var br = bytes.NewReader(bs)
|
||||
var xr = xdr.NewReader(br)
|
||||
return o.DecodeXDRFrom(xr)
|
||||
return o.UnmarshalXDRFrom(&xdr.Unmarshaller{Data: bs})
|
||||
}
|
||||
|
||||
func (o *FileInfoTruncated) DecodeXDRFrom(xr *xdr.Reader) error {
|
||||
o.Name = xr.ReadStringMax(8192)
|
||||
o.Flags = xr.ReadUint32()
|
||||
o.Modified = int64(xr.ReadUint64())
|
||||
(&o.Version).DecodeXDRFrom(xr)
|
||||
o.LocalVersion = int64(xr.ReadUint64())
|
||||
_BlocksSize := int(xr.ReadUint32())
|
||||
func (o *FileInfoTruncated) UnmarshalXDRFrom(u *xdr.Unmarshaller) error {
|
||||
o.Name = u.UnmarshalStringMax(8192)
|
||||
o.Flags = u.UnmarshalUint32()
|
||||
o.Modified = int64(u.UnmarshalUint64())
|
||||
(&o.Version).UnmarshalXDRFrom(u)
|
||||
o.LocalVersion = int64(u.UnmarshalUint64())
|
||||
_BlocksSize := int(u.UnmarshalUint32())
|
||||
if _BlocksSize < 0 {
|
||||
return xdr.ElementSizeExceeded("Blocks", _BlocksSize, 1000000)
|
||||
}
|
||||
if _BlocksSize > 1000000 {
|
||||
return xdr.ElementSizeExceeded("Blocks", _BlocksSize, 1000000)
|
||||
} else if _BlocksSize == 0 {
|
||||
o.Blocks = nil
|
||||
} else {
|
||||
if _BlocksSize > 1000000 {
|
||||
return xdr.ElementSizeExceeded("Blocks", _BlocksSize, 1000000)
|
||||
}
|
||||
for i := 0; i < _BlocksSize; i++ {
|
||||
size := int64(u.UnmarshalUint32())
|
||||
o.CachedSize += size
|
||||
u.UnmarshalBytes()
|
||||
}
|
||||
}
|
||||
|
||||
buf := make([]byte, 64)
|
||||
for i := 0; i < _BlocksSize; i++ {
|
||||
size := xr.ReadUint32()
|
||||
o.CachedSize += int64(size)
|
||||
xr.ReadBytesMaxInto(64, buf)
|
||||
}
|
||||
return xr.Error()
|
||||
return u.Error
|
||||
}
|
||||
|
||||
func BlocksToSize(num int) int64 {
|
||||
|
||||
Reference in New Issue
Block a user