Merge branch 'master' into dht-cleanup

This commit is contained in:
Matt Joiner 2017-08-07 17:59:49 +10:00
commit bbd63962ba
1 changed files with 7 additions and 4 deletions

View File

@ -32,6 +32,7 @@ func NewMMapWithCompletion(baseDir string, completion PieceCompletion) ClientImp
func (s *mmapStorage) OpenTorrent(info *metainfo.Info, infoHash metainfo.Hash) (t TorrentImpl, err error) {
span, err := mMapTorrent(info, s.baseDir)
t = &mmapTorrentStorage{
infoHash: infoHash,
span: span,
pc: s.pc,
}
@ -43,6 +44,7 @@ func (s *mmapStorage) Close() error {
}
type mmapTorrentStorage struct {
infoHash metainfo.Hash
span mmap_span.MMapSpan
pc PieceCompletion
}
@ -51,6 +53,7 @@ func (ts *mmapTorrentStorage) Piece(p metainfo.Piece) PieceImpl {
return mmapStoragePiece{
pc: ts.pc,
p: p,
ih: ts.infoHash,
ReaderAt: io.NewSectionReader(ts.span, p.Offset(), p.Length()),
WriterAt: missinggo.NewSectionWriter(ts.span, p.Offset(), p.Length()),
}