Skip to content

Commit 578cadc

Browse files
committed
file: Optimize put interface
Signed-off-by: swj <1186093704@qq.com>
1 parent 1b79d6e commit 578cadc

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

pkg/object/file.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func (d *filestore) Put(key string, in io.Reader) error {
135135
}()
136136
buf := bufPool.Get().(*[]byte)
137137
defer bufPool.Put(buf)
138-
_, err = io.CopyBuffer(f, in, *buf)
138+
_, err = io.CopyBuffer(onlyWriter{f}, in, *buf)
139139
if err != nil {
140140
_ = f.Close()
141141
return err

pkg/object/object_storage.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"context"
2121
"errors"
2222
"fmt"
23+
"io"
2324
"os"
2425
"sync"
2526
"time"
@@ -42,6 +43,10 @@ type File interface {
4243
Mode() os.FileMode
4344
}
4445

46+
type onlyWriter struct {
47+
io.Writer
48+
}
49+
4550
type file struct {
4651
obj
4752
owner string

0 commit comments

Comments
 (0)