aboutsummaryrefslogtreecommitdiff
path: root/go/storage/crc.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2014-07-22 00:24:50 -0700
committerChris Lu <chris.lu@gmail.com>2014-07-22 00:24:50 -0700
commit530927db64ea523db2efb4cff6fe5f12d9378d03 (patch)
tree1587f159b8fbb9ef6099d33dbedf6bbec4def9d4 /go/storage/crc.go
parent5d88cec2df569c5b13b94f258c5af831c71e3894 (diff)
downloadseaweedfs-530927db64ea523db2efb4cff6fe5f12d9378d03.tar.xz
seaweedfs-530927db64ea523db2efb4cff6fe5f12d9378d03.zip
Add Etag support
Diffstat (limited to 'go/storage/crc.go')
-rw-r--r--go/storage/crc.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/go/storage/crc.go b/go/storage/crc.go
index 198352e68..41f7f6d00 100644
--- a/go/storage/crc.go
+++ b/go/storage/crc.go
@@ -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)
+}