aboutsummaryrefslogtreecommitdiff
path: root/weed/util/bytes.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-10-20 23:48:29 -0700
committerChris Lu <chris.lu@gmail.com>2020-10-20 23:48:29 -0700
commitc31b2542489ea4cddffbf1efedbdb867fb6cdb2f (patch)
tree9762a4b1c79c6c27b83bfef3c3b285aa7a613c65 /weed/util/bytes.go
parentf64252023ee882264ea1b220afbdf0321e26a56b (diff)
downloadseaweedfs-c31b2542489ea4cddffbf1efedbdb867fb6cdb2f.tar.xz
seaweedfs-c31b2542489ea4cddffbf1efedbdb867fb6cdb2f.zip
mount: shortcut when there is only one chunk
Diffstat (limited to 'weed/util/bytes.go')
-rw-r--r--weed/util/bytes.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/weed/util/bytes.go b/weed/util/bytes.go
index 67e6876fa..c2a4df108 100644
--- a/weed/util/bytes.go
+++ b/weed/util/bytes.go
@@ -1,6 +1,7 @@
package util
import (
+ "bytes"
"crypto/md5"
"crypto/rand"
"encoding/base64"
@@ -148,3 +149,15 @@ func RandomBytes(byteCount int) []byte {
rand.Read(buf)
return buf
}
+
+type BytesReader struct {
+ Bytes []byte
+ *bytes.Reader
+}
+
+func NewBytesReader(b []byte) *BytesReader {
+ return &BytesReader{
+ Bytes: b,
+ Reader: bytes.NewReader(b),
+ }
+}