boltdbresumer

package
v1.8.10 Latest Latest
Warning

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

Go to latest
Published: May 6, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package boltdbresumer provides a Resumer implementation that uses a Bolt database file as storage.

Index

Constants

This section is empty.

Variables

View Source
var Keys = struct {
	InfoHash          []byte
	Port              []byte
	Name              []byte
	Trackers          []byte
	URLList           []byte
	FixedPeers        []byte
	Dest              []byte
	Info              []byte
	Bitfield          []byte
	AddedAt           []byte
	BytesDownloaded   []byte
	BytesUploaded     []byte
	BytesWasted       []byte
	SeededFor         []byte
	Started           []byte
	StopAfterDownload []byte
	StopAfterMetadata []byte
	CompleteCmdRun    []byte
}{
	InfoHash:          []byte("info_hash"),
	Port:              []byte("port"),
	Name:              []byte("name"),
	Trackers:          []byte("trackers"),
	URLList:           []byte("url_list"),
	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"),
	StopAfterDownload: []byte("stop_after_download"),
	StopAfterMetadata: []byte("stop_after_metadata"),
	CompleteCmdRun:    []byte("complete_cmd_run"),
}

Keys for the persisten storage.

Functions

This section is empty.

Types

type Resumer

type Resumer struct {
	// contains filtered or unexported fields
}

Resumer contains methods for saving/loading resume information of a torrent to a BoltDB database.

func New

func New(db *bbolt.DB, bucket []byte) (*Resumer, error)

New returns a new Resumer.

func (*Resumer) HandleStopAfterDownload added in v1.8.10

func (r *Resumer) HandleStopAfterDownload(torrentID string) error

HandleStopAfterDownload clears the start status and stop_after_download fields.

func (*Resumer) HandleStopAfterMetadata added in v1.8.10

func (r *Resumer) HandleStopAfterMetadata(torrentID string) error

HandleStopAfterMetadata clears the start status and stop_after_metadata fields.

func (*Resumer) Read

func (r *Resumer) Read(torrentID string) (spec *Spec, err error)

func (*Resumer) Write

func (r *Resumer) Write(torrentID string, spec *Spec) error

Write the torrent spec for torrent with `torrentID`.

func (*Resumer) WriteBitfield

func (r *Resumer) WriteBitfield(torrentID string, value []byte) error

WriteBitfield writes only bitfield of a torrent.

func (*Resumer) WriteCompleteCmdRun added in v1.8.10

func (r *Resumer) WriteCompleteCmdRun(torrentID string) error

WriteCompleteCmdRun writes the start status of a torrent.

func (*Resumer) WriteInfo

func (r *Resumer) WriteInfo(torrentID string, value []byte) error

WriteInfo writes only the info dict of a torrent.

func (*Resumer) WriteStarted added in v1.8.10

func (r *Resumer) WriteStarted(torrentID string, value bool) error

WriteStarted writes the start status of a torrent.

type Spec

type Spec struct {
	InfoHash          []byte
	Port              int
	Name              string
	Trackers          [][]string
	URLList           []string
	FixedPeers        []string
	Info              []byte
	Bitfield          []byte
	AddedAt           time.Time
	BytesDownloaded   int64
	BytesUploaded     int64
	BytesWasted       int64
	SeededFor         time.Duration
	Started           bool
	StopAfterDownload bool
	StopAfterMetadata bool
	CompleteCmdRun    bool
}

Spec contains fields for resuming an existing torrent.

func (Spec) MarshalJSON added in v1.8.10

func (s Spec) MarshalJSON() ([]byte, error)

MarshalJSON converts the Spec to a JSON string.

func (*Spec) UnmarshalJSON added in v1.8.10

func (s *Spec) UnmarshalJSON(b []byte) error

UnmarshalJSON fills the Spec from a JSON string.

Jump to

Keyboard shortcuts

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