Documentation ¶
Index ¶
- Constants
- func RenderDiffHeader(inputName1, key1, inputName2, key2 string) string
- type GetTorrentFunc
- type TorrentDiff
- func (d *TorrentDiff) AddChanged(file TorrentFileDiff)
- func (d *TorrentDiff) AddMissing(file TorrentFileDiff)
- func (d *TorrentDiff) AddNew(file TorrentFileDiff)
- func (d *TorrentDiff) AddUnchanged(file TorrentFileDiff)
- func (d *TorrentDiff) FPrint(w io.Writer)
- func (d *TorrentDiff) FPrintJSON(w io.Writer) error
- func (d *TorrentDiff) MarshalJSON() ([]byte, error)
- type TorrentDiffOption
- type TorrentFile
- type TorrentFileDiff
Constants ¶
const TorrentDBFile = "./.torrent.bolt.db"
Variables ¶
This section is empty.
Functions ¶
func RenderDiffHeader ¶ added in v0.2.0
RenderDiffHeader renders the diff header given the input names and keys.
Types ¶
type TorrentDiff ¶
type TorrentDiff struct { Unchanged []TorrentFileDiff `json:"unchanged"` Changed []TorrentFileDiff `json:"changed"` Missing []TorrentFileDiff `json:"missing"` New []TorrentFileDiff `json:"new"` // contains filtered or unexported fields }
TorrentDiff holds all the diffing information for all the files under a torrent.
func BuildTorrentDiff ¶
func BuildTorrentDiff( torrentFiles1 []TorrentFile, torrentFiles2 []TorrentFile, opts ...TorrentDiffOption, ) TorrentDiff
BuildTorrentDiff calculates the file diffs for the two given torrent file slices, where torrentFile1 is being compared against torrentFile2.
func NewTorrentDiff ¶
func NewTorrentDiff(opts ...TorrentDiffOption) TorrentDiff
NewTorrentDiff creates a new default-initalized TorrentDiff.
func (*TorrentDiff) AddChanged ¶
func (d *TorrentDiff) AddChanged(file TorrentFileDiff)
AddChanged adds a diff for a file that has changed across versions.
func (*TorrentDiff) AddMissing ¶
func (d *TorrentDiff) AddMissing(file TorrentFileDiff)
AddMissing adds a diff for a file that exists in the old torrent but does not exist in the new torrent.
func (*TorrentDiff) AddNew ¶
func (d *TorrentDiff) AddNew(file TorrentFileDiff)
AddNew adds a diff for a file that exists in the new torrent but does not exist in the old torrent.
func (*TorrentDiff) AddUnchanged ¶
func (d *TorrentDiff) AddUnchanged(file TorrentFileDiff)
AddUnchanged adds a diff for a file that is unchanged across versions.
func (*TorrentDiff) FPrint ¶
func (d *TorrentDiff) FPrint(w io.Writer)
FPrint handles displaying the torrent's diff in human-readable format.
func (*TorrentDiff) FPrintJSON ¶
func (d *TorrentDiff) FPrintJSON(w io.Writer) error
FPrintJSON handles displaying the torrent's diff as JSON.
func (*TorrentDiff) MarshalJSON ¶
func (d *TorrentDiff) MarshalJSON() ([]byte, error)
MarshalJSON overrides the default JSON implementation to exclude `unchanged` if necessary
type TorrentDiffOption ¶
type TorrentDiffOption func(diff *TorrentDiff)
TorrentDiffOption represents an option that can be defined when creating a TorrentDiff object.
func TorrentDiffWithPathPrefix ¶
func TorrentDiffWithPathPrefix(prefix string) TorrentDiffOption
TorrentDiffWithPathPrefix configured a prefix to show at the beginning of each torrent file in a diff output.
func TorrentDiffWithShowUnchanged ¶
func TorrentDiffWithShowUnchanged(show bool) TorrentDiffOption
TorrentDiffWithShowUnchanged dictates whether unchanged files should be displayed in the diff output.
type TorrentFile ¶
type TorrentFile struct { Path string `json:"-"` Size int64 `json:"size"` SizeKnown bool `json:"size_known"` }
TorrentFile represents a single file under a torrent or local download.
func GetFilesForMagnet ¶
func GetFilesForMagnet(magnetURL string) ([]TorrentFile, error)
GetFilesForMagnet gets all file under the given magnet URL.
func GetFilesForTorrent ¶
func GetFilesForTorrent(torrentFile string) ([]TorrentFile, error)
GetFilesForTorrent gets all file under the given torrent file.
func TranslateTorrentFile ¶
func TranslateTorrentFile(f *torrent.File) TorrentFile
TranslateTorrentFile translates the given `anacrolix/torrent` file into a torrentHelper TorrentFile.
type TorrentFileDiff ¶
type TorrentFileDiff struct { Path string `json:"path"` Old *TorrentFile `json:"old"` New *TorrentFile `json:"new"` }
TorrentFileDiff represents the diff between two versions of a torrent file.
func (TorrentFileDiff) FormatNewSize ¶
func (d TorrentFileDiff) FormatNewSize() string
FormatNewSize formats the size of the new file for use in diff outputs.
func (TorrentFileDiff) FormatOldSize ¶
func (d TorrentFileDiff) FormatOldSize() string
FormatOldSize formats the size of the old file for use in diff outputs.