aboutsummaryrefslogtreecommitdiff
path: root/weed/filer2/entry_codec.go
diff options
context:
space:
mode:
Diffstat (limited to 'weed/filer2/entry_codec.go')
-rw-r--r--weed/filer2/entry_codec.go51
1 files changed, 40 insertions, 11 deletions
diff --git a/weed/filer2/entry_codec.go b/weed/filer2/entry_codec.go
index baa6a9440..3a2dc6134 100644
--- a/weed/filer2/entry_codec.go
+++ b/weed/filer2/entry_codec.go
@@ -1,18 +1,21 @@
package filer2
import (
+ "bytes"
+ "fmt"
"os"
"time"
- "fmt"
+ "github.com/golang/protobuf/proto"
+
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
- "github.com/gogo/protobuf/proto"
)
func (entry *Entry) EncodeAttributesAndChunks() ([]byte, error) {
message := &filer_pb.Entry{
Attributes: EntryAttributeToPb(entry),
Chunks: entry.Chunks,
+ Extended: entry.Extended,
}
return proto.Marshal(message)
}
@@ -27,6 +30,8 @@ func (entry *Entry) DecodeAttributesAndChunks(blob []byte) error {
entry.Attr = PbToEntryAttribute(message.Attributes)
+ entry.Extended = message.Extended
+
entry.Chunks = message.Chunks
return nil
@@ -35,15 +40,18 @@ func (entry *Entry) DecodeAttributesAndChunks(blob []byte) error {
func EntryAttributeToPb(entry *Entry) *filer_pb.FuseAttributes {
return &filer_pb.FuseAttributes{
- Crtime: entry.Attr.Crtime.Unix(),
- Mtime: entry.Attr.Mtime.Unix(),
- FileMode: uint32(entry.Attr.Mode),
- Uid: entry.Uid,
- Gid: entry.Gid,
- Mime: entry.Mime,
- Collection: entry.Attr.Collection,
- Replication: entry.Attr.Replication,
- TtlSec: entry.Attr.TtlSec,
+ Crtime: entry.Attr.Crtime.Unix(),
+ Mtime: entry.Attr.Mtime.Unix(),
+ FileMode: uint32(entry.Attr.Mode),
+ Uid: entry.Uid,
+ Gid: entry.Gid,
+ Mime: entry.Mime,
+ Collection: entry.Attr.Collection,
+ Replication: entry.Attr.Replication,
+ TtlSec: entry.Attr.TtlSec,
+ UserName: entry.Attr.UserName,
+ GroupName: entry.Attr.GroupNames,
+ SymlinkTarget: entry.Attr.SymlinkTarget,
}
}
@@ -60,6 +68,9 @@ func PbToEntryAttribute(attr *filer_pb.FuseAttributes) Attr {
t.Collection = attr.Collection
t.Replication = attr.Replication
t.TtlSec = attr.TtlSec
+ t.UserName = attr.UserName
+ t.GroupNames = attr.GroupName
+ t.SymlinkTarget = attr.SymlinkTarget
return t
}
@@ -78,6 +89,10 @@ func EqualEntry(a, b *Entry) bool {
return false
}
+ if !eq(a.Extended, b.Extended) {
+ return false
+ }
+
for i := 0; i < len(a.Chunks); i++ {
if !proto.Equal(a.Chunks[i], b.Chunks[i]) {
return false
@@ -85,3 +100,17 @@ func EqualEntry(a, b *Entry) bool {
}
return true
}
+
+func eq(a, b map[string][]byte) bool {
+ if len(a) != len(b) {
+ return false
+ }
+
+ for k, v := range a {
+ if w, ok := b[k]; !ok || !bytes.Equal(v, w) {
+ return false
+ }
+ }
+
+ return true
+}