storage

package
v0.0.0-...-796776c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2017 License: MPL-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package storage implements storage backends for package torrent.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateNativeZeroLengthFiles

func CreateNativeZeroLengthFiles(info *metainfo.Info, dir string) (err error)

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.

Types

type Client

type Client struct {
	ClientImpl
}

func NewClient

func NewClient(cl ClientImpl) *Client

func (Client) OpenTorrent

func (cl Client) OpenTorrent(info *metainfo.Info, infoHash metainfo.Hash) (*Torrent, error)

type ClientImpl

type ClientImpl interface {
	OpenTorrent(info *metainfo.Info, infoHash metainfo.Hash) (TorrentImpl, error)
	Close() error
}

Represents data storage for an unspecified torrent.

func NewBoltDB

func NewBoltDB(filePath string) ClientImpl

func NewFile

func NewFile(baseDir string) ClientImpl

All Torrent data stored in this baseDir

func NewFileByInfoHash

func NewFileByInfoHash(baseDir string) ClientImpl

All Torrent data stored in subdirectorys 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

func NewMMap

func NewMMap(baseDir string) ClientImpl

func NewResourcePieces

func NewResourcePieces(p resource.Provider) ClientImpl

type Piece

type Piece struct {
	PieceImpl
	// contains filtered or unexported fields
}

func (Piece) ReadAt

func (p Piece) ReadAt(b []byte, off int64) (n int, err error)

func (Piece) WriteAt

func (p Piece) WriteAt(b []byte, off int64) (n int, err error)

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.
	GetIsComplete() bool
}

Interacts with torrent piece data.

type Torrent

type Torrent struct {
	TorrentImpl
}

func (Torrent) Piece

func (t Torrent) Piece(p metainfo.Piece) Piece

type TorrentImpl

type TorrentImpl interface {
	Piece(metainfo.Piece) PieceImpl
	Close() error
}

Data storage bound to a torrent.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL