Add Etag support

This commit is contained in:
Chris Lu
2014-07-22 00:24:50 -07:00
parent 5d88cec2df
commit 530927db64
2 changed files with 14 additions and 0 deletions

View File

@@ -1,6 +1,8 @@
package storage
import (
"code.google.com/p/weed-fs/go/util"
"fmt"
"hash/crc32"
)
@@ -19,3 +21,9 @@ func (c CRC) Update(b []byte) CRC {
func (c CRC) Value() uint32 {
return uint32(c>>15|c<<17) + 0xa282ead8
}
func (n *Needle) Etag() string {
bits := make([]byte, 4)
util.Uint32toBytes(bits, uint32(n.Checksum))
return fmt.Sprintf("%x", bits)
}