data/pieceStore: Expose flags in Open method
This commit is contained in:
parent
ea0ccf6a23
commit
4c4eae20a2
|
@ -39,8 +39,8 @@ func (me *backend) GetLength(path string) (ret int64, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func (me *backend) Open(path string) (ret dataBackend.File, err error) {
|
||||
ret, err = me.c.OpenFile(path, os.O_RDWR|os.O_CREATE)
|
||||
func (me *backend) Open(path string, flag int) (ret dataBackend.File, err error) {
|
||||
ret, err = me.c.OpenFile(path, flag)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -52,8 +52,8 @@ func (me *backend) GetLength(path string) (ret int64, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func (me *backend) Open(path string) (ret dataBackend.File, err error) {
|
||||
ret = httpfile.Open(me.urlStr(path))
|
||||
func (me *backend) Open(path string, flag int) (ret dataBackend.File, err error) {
|
||||
ret = httpfile.Open(me.urlStr(path), flag)
|
||||
err = fixErrNotFound(err)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
// All functions must return ErrNotFound as required.
|
||||
type I interface {
|
||||
GetLength(path string) (int64, error)
|
||||
Open(path string) (File, error)
|
||||
Open(path string, flags int) (File, error)
|
||||
OpenSection(path string, off, n int64) (io.ReadCloser, error)
|
||||
Delete(path string) error
|
||||
}
|
||||
|
@ -19,4 +19,5 @@ type File interface {
|
|||
io.Closer
|
||||
io.Seeker
|
||||
io.Writer
|
||||
io.Reader
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ func (me *store) pieceWriteAt(p metainfo.Piece, b []byte, off int64) (n int, err
|
|||
defer func() {
|
||||
<-me.requestPool
|
||||
}()
|
||||
f, err := me.db.Open(me.incompletePiecePath(p))
|
||||
f, err := me.db.Open(me.incompletePiecePath(p), os.O_WRONLY|os.O_CREATE)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ func (me *store) hashCopyFile(from, to string, n int64) (hash []byte, err error)
|
|||
defer src.Close()
|
||||
hasher := sha1.New()
|
||||
tee := io.TeeReader(src, hasher)
|
||||
dest, err := me.db.Open(to)
|
||||
dest, err := me.db.Open(to, os.O_WRONLY|os.O_CREATE)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue