From baa8c1aed231df3b170acb211437a251e854bf4c Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Tue, 29 Mar 2016 12:13:03 +1100 Subject: [PATCH] Few fixes for downstream projects --- storage/piece_file.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/storage/piece_file.go b/storage/piece_file.go index 0e323751..9bda947e 100644 --- a/storage/piece_file.go +++ b/storage/piece_file.go @@ -1,6 +1,7 @@ package storage import ( + "io" "os" "path" @@ -14,12 +15,16 @@ type FileStore interface { OpenFile(path string, flags int) (File, error) Stat(path string) (os.FileInfo, error) Rename(from, to string) error + Remove(path string) error } type File interface { - WriteAt([]byte, int64) (int, error) - ReadAt([]byte, int64) (int, error) - Close() error + io.ReaderAt + io.WriterAt + io.Writer + io.Reader + io.Closer + io.Seeker } type FileCacheFileStore struct { @@ -83,6 +88,10 @@ func (me pieceFileTorrentStoragePiece) ReadAt(b []byte, off int64) (n int, err e f, err := me.fs.OpenFile(me.completedPath(), os.O_RDONLY) if err != nil { f, err = me.fs.OpenFile(me.incompletePath(), os.O_RDONLY) + if os.IsNotExist(err) { + err = io.ErrUnexpectedEOF + return + } if err != nil { return } -- 2.48.1