mirror of
https://github.com/anyproto/anytype-heart.git
synced 2025-06-10 18:10:49 +09:00
fix copy struct
This commit is contained in:
parent
dac849175f
commit
88c05033e3
3 changed files with 21 additions and 7 deletions
|
@ -367,9 +367,9 @@ func (c *collector) close() {
|
|||
}
|
||||
|
||||
func copyMeta(m Meta) Meta {
|
||||
var d *types.Struct
|
||||
d := m.Details
|
||||
if d != nil {
|
||||
d = pbtypes.CopyStruct(m.SmartBlockMeta.Details)
|
||||
d = pbtypes.CopyStruct(m.Details)
|
||||
}
|
||||
return Meta{
|
||||
BlockId:
|
||||
|
|
|
@ -13,11 +13,6 @@ var bytesPool = &sync.Pool{
|
|||
},
|
||||
}
|
||||
|
||||
type Type interface {
|
||||
Size() int
|
||||
MarshalToSizedBuffer(data []byte) (int, error)
|
||||
}
|
||||
|
||||
func CopyBlock(in *model.Block) (out *model.Block) {
|
||||
buf := bytesPool.Get().([]byte)
|
||||
size := in.Size()
|
||||
|
|
19
util/pbtypes/copy_test.go
Normal file
19
util/pbtypes/copy_test.go
Normal file
|
@ -0,0 +1,19 @@
|
|||
package pbtypes
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/gogo/protobuf/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestCopyStruct(t *testing.T) {
|
||||
s := &types.Struct{
|
||||
Fields: map[string]*types.Value{
|
||||
"string": String("string"),
|
||||
"bool": Bool(true),
|
||||
},
|
||||
}
|
||||
c := CopyStruct(s)
|
||||
assert.True(t, s.Equal(c))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue