Documentation ¶
Overview ¶
Package storage implements storage backends for package torrent.
Index ¶
- func CreateNativeZeroLengthFiles(info *metainfo.Info, dir string) (err error)
- func NewFileWithCompletion(baseDir string, completion PieceCompletion) *fileClientImpl
- func NewMMapWithCompletion(baseDir string, completion PieceCompletion) *mmapClientImpl
- func NewSqlitePieceCompletion(dir string) (ret *sqlitePieceCompletion, err error)
- type Client
- type ClientImpl
- type ClientImplCloser
- type Completion
- type Piece
- type PieceCompletion
- type PieceCompletionGetSetter
- type PieceImpl
- type Torrent
- type TorrentImpl
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateNativeZeroLengthFiles ¶
Creates natives files for any zero-length file entries in the info. This is a helper for file-based storages, which don't address or write to zero- length files because they have no corresponding pieces.
func NewFileWithCompletion ¶
func NewFileWithCompletion(baseDir string, completion PieceCompletion) *fileClientImpl
func NewMMapWithCompletion ¶
func NewMMapWithCompletion(baseDir string, completion PieceCompletion) *mmapClientImpl
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(cl ClientImpl) *Client
type ClientImpl ¶
type ClientImpl interface {
OpenTorrent(info *metainfo.Info, infoHash metainfo.Hash) (TorrentImpl, error)
}
Represents data storage for an unspecified torrent.
func NewFileByInfoHash ¶
func NewFileByInfoHash(baseDir string) ClientImpl
File storage with data partitioned by infohash.
func NewFileWithCustomPathMaker ¶
func NewFileWithCustomPathMaker(baseDir string, pathMaker func(baseDir string, info *metainfo.Info, infoHash metainfo.Hash) string) ClientImpl
Allows passing a function to determine the path for storing torrent data
type ClientImplCloser ¶ added in v1.15.0
type ClientImplCloser interface { ClientImpl Close() error }
func NewBoltDB ¶
func NewBoltDB(filePath string) ClientImplCloser
func NewFile ¶
func NewFile(baseDir string) ClientImplCloser
All Torrent data stored in this baseDir
func NewMMap ¶
func NewMMap(baseDir string) ClientImplCloser
func NewResourcePieces ¶
func NewResourcePieces(p resource.Provider) ClientImplCloser
type Completion ¶
type PieceCompletion ¶
type PieceCompletion interface { PieceCompletionGetSetter Close() error }
Implementations track the completion of pieces. It must be concurrent-safe.
func NewBoltPieceCompletion ¶
func NewBoltPieceCompletion(dir string) (ret PieceCompletion, err error)
func NewMapPieceCompletion ¶
func NewMapPieceCompletion() PieceCompletion
type PieceImpl ¶
type PieceImpl interface { // These interfaces are not as strict as normally required. They can // assume that the parameters are appropriate for the dimensions of the // piece. io.ReaderAt io.WriterAt // Called when the client believes the piece data will pass a hash check. // The storage can move or mark the piece data as read-only as it sees // fit. MarkComplete() error MarkNotComplete() error // Returns true if the piece is complete. Completion() Completion }
Interacts with torrent piece data.
type Torrent ¶
type Torrent struct {
TorrentImpl
}
Click to show internal directories.
Click to hide internal directories.