diff options
| author | Chris Lu <chris.lu@gmail.com> | 2020-11-30 04:34:04 -0800 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2020-11-30 04:34:04 -0800 |
| commit | f4abd01adf9fb2ebdefa844b2a4f0aaf8eeb1ccc (patch) | |
| tree | 87406670846a99820d7b6bb37dc3d2cf9362a9de /weed/filer | |
| parent | a9c6be5fc3fffad6403ce63aa3951121491eb1d1 (diff) | |
| download | seaweedfs-f4abd01adf9fb2ebdefa844b2a4f0aaf8eeb1ccc.tar.xz seaweedfs-f4abd01adf9fb2ebdefa844b2a4f0aaf8eeb1ccc.zip | |
filer: cache small file to filer store
Diffstat (limited to 'weed/filer')
| -rw-r--r-- | weed/filer/entry.go | 3 | ||||
| -rw-r--r-- | weed/filer/entry_codec.go | 5 | ||||
| -rw-r--r-- | weed/filer/filer_conf.go | 4 |
3 files changed, 12 insertions, 0 deletions
diff --git a/weed/filer/entry.go b/weed/filer/entry.go index 421e51432..d2f257967 100644 --- a/weed/filer/entry.go +++ b/weed/filer/entry.go @@ -40,6 +40,7 @@ type Entry struct { HardLinkId HardLinkId HardLinkCounter int32 + Content []byte } func (entry *Entry) Size() uint64 { @@ -66,6 +67,7 @@ func (entry *Entry) ToProtoEntry() *filer_pb.Entry { Extended: entry.Extended, HardLinkId: entry.HardLinkId, HardLinkCounter: entry.HardLinkCounter, + Content: entry.Content, } } @@ -98,6 +100,7 @@ func FromPbEntry(dir string, entry *filer_pb.Entry) *Entry { Chunks: entry.Chunks, HardLinkId: HardLinkId(entry.HardLinkId), HardLinkCounter: entry.HardLinkCounter, + Content: entry.Content, } } diff --git a/weed/filer/entry_codec.go b/weed/filer/entry_codec.go index 884fb2670..1693b551e 100644 --- a/weed/filer/entry_codec.go +++ b/weed/filer/entry_codec.go @@ -18,6 +18,7 @@ func (entry *Entry) EncodeAttributesAndChunks() ([]byte, error) { Extended: entry.Extended, HardLinkId: entry.HardLinkId, HardLinkCounter: entry.HardLinkCounter, + Content: entry.Content, } return proto.Marshal(message) } @@ -38,6 +39,7 @@ func (entry *Entry) DecodeAttributesAndChunks(blob []byte) error { entry.HardLinkId = message.HardLinkId entry.HardLinkCounter = message.HardLinkCounter + entry.Content = message.Content return nil } @@ -122,6 +124,9 @@ func EqualEntry(a, b *Entry) bool { if a.HardLinkCounter != b.HardLinkCounter { return false } + if !bytes.Equal(a.Content, b.Content) { + return false + } return true } diff --git a/weed/filer/filer_conf.go b/weed/filer/filer_conf.go index 6aa0d2b87..0328fdbff 100644 --- a/weed/filer/filer_conf.go +++ b/weed/filer/filer_conf.go @@ -40,6 +40,10 @@ func (fc *FilerConf) loadFromFiler(filer *Filer) (err error) { return } + if len(entry.Content) > 0 { + return fc.LoadFromBytes(entry.Content) + } + return fc.loadFromChunks(filer, entry.Chunks) } |
