Commit f4a90b6b authored by Kirill Smelkov's avatar Kirill Smelkov

X go/neo/sqlite: Empty hash means zero hash

This fixes

    === RUN   TestLoad/go/!ssl
    I: runneo.py: /tmp/neo907773749/1 !ssl: started master(s): 127.0.0.1:25540
    I: runneo.py: /tmp/neo907773749/1 !ssl: terminated
    I: runneo.py: /tmp/neo907773749/1 !ssl: started master(s): 127.0.0.1:21414
    I: runneo.py: /tmp/neo907773749/1 !ssl: terminated
        xtesting.go:297: load 0285cbacc06d3a4c:0000000000000007: returned err unexpected:
            have: neo://[::]:42091/1: load 0285cbacc06d3a4c:0000000000000007: NOT_READY: data corrupt: len(hash) = 0
            want: neo://[::]:42091/1: load 0285cbacc06d3a4c:0000000000000007: 0000000000000007: object was deleted @0285cbacc06d3a4c
        xtesting.go:297: load 0285cbad858bf2e6:0000000000000006: returned err unexpected:
            have: neo://[::]:42091/1: load 0285cbad858bf2e6:0000000000000006: NOT_READY: data corrupt: len(hash) = 0
            want: neo://[::]:42091/1: load 0285cbad858bf2e6:0000000000000006: 0000000000000006: object was deleted @0285cbad858bf2e6
        xtesting.go:318: load 7fffffffffffffff:0000000000000006: returned err unexpected:
            have: neo://[::]:42091/1: load 7fffffffffffffff:0000000000000006: NOT_READY: data corrupt: len(hash) = 0
            want: neo://[::]:42091/1: load 7fffffffffffffff:0000000000000006: 0000000000000006: object was deleted @0285cbad858bf2e6
        xtesting.go:318: load 7fffffffffffffff:0000000000000007: returned err unexpected:
            have: neo://[::]:42091/1: load 7fffffffffffffff:0000000000000007: NOT_READY: data corrupt: len(hash) = 0
            want: neo://[::]:42091/1: load 7fffffffffffffff:0000000000000007: 0000000000000007: object was deleted @0285cbacc06d3a4c

See also bc2cddfc (X go/neo: Switch to NEO-kind SHA1)
parent 97af779d
......@@ -358,10 +358,17 @@ func (b *Backend) Load(ctx context.Context, xid zodb.Xid) (_ *proto.AnswerObject
}
// hash -> obj.Checksum
if len(hash) != len(obj.Checksum) {
switch {
case len(hash) == 0:
// empty hash -> all zeros
// obj.Checksum stays at zero value
case len(hash) != len(obj.Checksum):
return nil, fmt.Errorf("data corrupt: len(hash) = %d", len(hash))
default:
copy(obj.Checksum[:], hash)
}
copy(obj.Checksum[:], hash)
// valueTid -> obj.DataSerial
if valueTid != 0 {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment