Add some comments to file storage
This commit is contained in:
parent
cee49435e0
commit
0aabd37e6e
|
@ -10,6 +10,8 @@ import (
|
||||||
"github.com/anacrolix/torrent/metainfo"
|
"github.com/anacrolix/torrent/metainfo"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// File-based storage for torrents, that isn't yet bound to a particular
|
||||||
|
// torrent.
|
||||||
type fileStorage struct {
|
type fileStorage struct {
|
||||||
baseDir string
|
baseDir string
|
||||||
completed map[[20]byte]bool
|
completed map[[20]byte]bool
|
||||||
|
@ -25,15 +27,18 @@ func (fs *fileStorage) OpenTorrent(info *metainfo.InfoEx) (Torrent, error) {
|
||||||
return fileTorrentStorage{fs}, nil
|
return fileTorrentStorage{fs}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// File-based torrent storage, not yet bound to a Torrent.
|
||||||
type fileTorrentStorage struct {
|
type fileTorrentStorage struct {
|
||||||
*fileStorage
|
*fileStorage
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fs *fileStorage) Piece(p metainfo.Piece) Piece {
|
func (fs *fileStorage) Piece(p metainfo.Piece) Piece {
|
||||||
|
// Create a view onto the file-based torrent storage.
|
||||||
_io := &fileStorageTorrent{
|
_io := &fileStorageTorrent{
|
||||||
p.Info,
|
p.Info,
|
||||||
fs.baseDir,
|
fs.baseDir,
|
||||||
}
|
}
|
||||||
|
// Return the appropriate segments of this.
|
||||||
return &fileStoragePiece{
|
return &fileStoragePiece{
|
||||||
fs,
|
fs,
|
||||||
p,
|
p,
|
||||||
|
@ -65,6 +70,7 @@ func (fs *fileStoragePiece) MarkComplete() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Exposes file-based storage of a torrent, as one big ReadWriterAt.
|
||||||
type fileStorageTorrent struct {
|
type fileStorageTorrent struct {
|
||||||
info *metainfo.InfoEx
|
info *metainfo.InfoEx
|
||||||
baseDir string
|
baseDir string
|
||||||
|
|
Loading…
Reference in New Issue