diff options
| author | Chris Lu <chris.lu@gmail.com> | 2020-10-20 23:48:29 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2020-10-20 23:48:29 -0700 |
| commit | c31b2542489ea4cddffbf1efedbdb867fb6cdb2f (patch) | |
| tree | 9762a4b1c79c6c27b83bfef3c3b285aa7a613c65 /weed/util/bytes.go | |
| parent | f64252023ee882264ea1b220afbdf0321e26a56b (diff) | |
| download | seaweedfs-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.go | 13 |
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), + } +} |
