Documentation ¶
Overview ¶
Package boltdbresumer provides a Resumer implementation that uses a Bolt database file as storage.
Index ¶
- Variables
- type SessionResumer
- type SessionSpec
- type Spec
- type TorrentResumer
- func (r *TorrentResumer) Del() error
- func (r *TorrentResumer) Read(torrentID string) (spec *Spec, err error)
- func (r *TorrentResumer) Write(torrentID string, spec *Spec) error
- func (r *TorrentResumer) WriteBitfield(torrentID string, value []byte) error
- func (r *TorrentResumer) WriteInfo(torrentID string, value []byte) error
- func (r *TorrentResumer) WriteStarted(torrentID string, value bool) error
Constants ¶
This section is empty.
Variables ¶
var Keys = struct { InfoHash []byte Name []byte FixedPeers []byte Dest []byte Info []byte Bitfield []byte AddedAt []byte BytesDownloaded []byte BytesUploaded []byte BytesWasted []byte SeededFor []byte Started []byte //add DataDir []byte //session UserPrivk []byte TorrentIds []byte }{ InfoHash: []byte("info_hash"), Name: []byte("name"), FixedPeers: []byte("fixed_peers"), Dest: []byte("dest"), Info: []byte("info"), Bitfield: []byte("bitfield"), AddedAt: []byte("added_at"), BytesDownloaded: []byte("bytes_downloaded"), BytesUploaded: []byte("bytes_uploaded"), BytesWasted: []byte("bytes_wasted"), SeededFor: []byte("seeded_for"), Started: []byte("started"), DataDir: []byte("data_dir"), UserPrivk: []byte("user_privk"), TorrentIds: []byte("torrentIds"), }
Keys for the persisten storage.
Functions ¶
This section is empty.
Types ¶
type SessionResumer ¶
type SessionResumer struct {
// contains filtered or unexported fields
}
Resumer contains methods for saving/loading resume information of a torrent to a BoltDB database.
func NewSessionResumer ¶
New returns a new Resumer.
func (*SessionResumer) Del ¶
func (r *SessionResumer) Del() error
func (*SessionResumer) Read ¶
func (r *SessionResumer) Read() (spec *SessionSpec, err error)
func (*SessionResumer) Write ¶
func (r *SessionResumer) Write(spec *SessionSpec) error
func (*SessionResumer) WriteTorrentIds ¶
func (r *SessionResumer) WriteTorrentIds(torrentIds []string) error
type SessionSpec ¶
type Spec ¶
type Spec struct { InfoHash []byte Name string FixedPeers []string Info []byte Bitfield []byte AddedAt time.Time BytesDownloaded int64 BytesUploaded int64 BytesWasted int64 SeededFor time.Duration Started bool StopAfterDownload bool //add DataDir string }
Spec contains fields for resuming an existing torrent.
func (Spec) MarshalJSON ¶
MarshalJSON converts the Spec to a JSON string.
func (*Spec) UnmarshalJSON ¶
UnmarshalJSON fills the Spec from a JSON string.
type TorrentResumer ¶
type TorrentResumer struct {
// contains filtered or unexported fields
}
Resumer contains methods for saving/loading resume information of a torrent to a BoltDB database.
func NewTorrentResumer ¶
New returns a new Resumer.
func (*TorrentResumer) Del ¶
func (r *TorrentResumer) Del() error
func (*TorrentResumer) Read ¶
func (r *TorrentResumer) Read(torrentID string) (spec *Spec, err error)
func (*TorrentResumer) Write ¶
func (r *TorrentResumer) Write(torrentID string, spec *Spec) error
Write the torrent spec for torrent with `torrentID`.
func (*TorrentResumer) WriteBitfield ¶
func (r *TorrentResumer) WriteBitfield(torrentID string, value []byte) error
WriteBitfield writes only bitfield of a torrent.
func (*TorrentResumer) WriteInfo ¶
func (r *TorrentResumer) WriteInfo(torrentID string, value []byte) error
WriteInfo writes only the info dict of a torrent.
func (*TorrentResumer) WriteStarted ¶
func (r *TorrentResumer) WriteStarted(torrentID string, value bool) error
WriteStarted writes the start status of a torrent.