mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
fix nil piece
This commit is contained in:
@@ -83,7 +83,7 @@ func (c *Cache) Piece(m metainfo.Piece) storage.PieceImpl {
|
|||||||
if val, ok := c.pieces[m.Index()]; ok {
|
if val, ok := c.pieces[m.Index()]; ok {
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
return nil
|
return &PieceFake{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cache) Close() error {
|
func (c *Cache) Close() error {
|
||||||
|
|||||||
33
server/torr/storage/torrstor/piecefake.go
Normal file
33
server/torr/storage/torrstor/piecefake.go
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
package torrstor
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"github.com/anacrolix/torrent/storage"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PieceFake struct{}
|
||||||
|
|
||||||
|
func (PieceFake) ReadAt(p []byte, off int64) (n int, err error) {
|
||||||
|
err = errors.New("fake")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (PieceFake) WriteAt(p []byte, off int64) (n int, err error) {
|
||||||
|
err = errors.New("fake")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (PieceFake) MarkComplete() error {
|
||||||
|
return errors.New("fake")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (PieceFake) MarkNotComplete() error {
|
||||||
|
return errors.New("fake")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (PieceFake) Completion() storage.Completion {
|
||||||
|
return storage.Completion{
|
||||||
|
Complete: false,
|
||||||
|
Ok: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user