diff options
| author | Chris Lu <chris.lu@gmail.com> | 2020-04-08 08:12:00 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2020-04-08 08:12:00 -0700 |
| commit | ec2eb8bc4804f9b880f256a55e3cbfc0923b6a29 (patch) | |
| tree | e0484d192fd361f1a0039492bcfffd75de1567db /weed/filer2/filechunks.go | |
| parent | 2d7d4b1006a8cd1f7af6244672541e9ac16bfac9 (diff) | |
| download | seaweedfs-ec2eb8bc4804f9b880f256a55e3cbfc0923b6a29.tar.xz seaweedfs-ec2eb8bc4804f9b880f256a55e3cbfc0923b6a29.zip | |
add If-None-Match and If-Modified-Since
fix https://github.com/chrislusf/seaweedfs/issues/1269
Diffstat (limited to 'weed/filer2/filechunks.go')
| -rw-r--r-- | weed/filer2/filechunks.go | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/weed/filer2/filechunks.go b/weed/filer2/filechunks.go index 0c93c389b..e8e4c305b 100644 --- a/weed/filer2/filechunks.go +++ b/weed/filer2/filechunks.go @@ -20,7 +20,21 @@ func TotalSize(chunks []*filer_pb.FileChunk) (size uint64) { return } -func ETag(chunks []*filer_pb.FileChunk) (etag string) { +func ETag(entry *filer_pb.Entry) (etag string) { + if entry.Attributes == nil || entry.Attributes.Md5 == nil { + ETagChunks(entry.Chunks) + } + return fmt.Sprintf("%x", entry.Attributes.Md5) +} + +func ETagEntry(entry *Entry) (etag string) { + if entry.Attr.Md5 == nil { + ETagChunks(entry.Chunks) + } + return fmt.Sprintf("%x", entry.Attr.Md5) +} + +func ETagChunks(chunks []*filer_pb.FileChunk) (etag string) { if len(chunks) == 1 { return chunks[0].ETag } |
