Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ERR_FILEINFO_ASSEMBLE_BLOCKS = errors.New("ERR_FILEINFO_ASSEMBLE_BLOCKS")
View Source
var ERR_FILEINFO_ASSEMBLE_BLOCKS__ALREADY_EXISTS = errors.New(
"ERR_FILEINFO_ASSEMBLE_BLOCKS__ALREADY_EXISTS")
View Source
var ERR_FILEINFO_READ_DOWNLOADED_DATA = errors.New("ERR_FILEINFO_READ_DOWNLOADED_DATA")
Functions ¶
func DefaultFinalizeFunc ¶
Finalize is called when all self.Pieces are done downloading. It is called from the PIECE msg handler of the last PIECE msg we receive. It does the following:
- Assemble all downloaded blocks (in 'self.DownloadedBlocksDir') to 'self.FinalDownloadDir'
- Enters 'seeding' state
Types ¶
type FileInfo ¶
type FileInfo struct { DownloadedBlocksDir string // TODO For now, this is only accommodating for single-file torrents FinalDownloadDir string IsSeeding bool Pieces piece.SafePieces FinalizeFunc FinalizeFunc // contains filtered or unexported fields }
For simplicity, we can limit one peer to one torrent
since the AnnounceResponse gives me back specific peers for a specific torrent, we can couple a peer with a torrent cleanly
func NewFileInfo ¶
func NewFileInfo( totalPieces int, pieceLength int64, blockLength int, finalDownloadDir string, downloadedBlocksDir string, torrentInfo *metainfo.Info, finalizeFunc FinalizeFunc, isSeeding bool, ) (*FileInfo, error)
NewFileInfo takes 'totalPieces' and 'pieceLength' and constructs blocks and pieces out of it XXX We're NOT allocating empty bytes for each block: this will be very wasteful: we will just write directly to disk
func (*FileInfo) DeleteBlocksDir ¶
func (self *FileInfo) DeleteBlocksDir()
func (*FileInfo) DeleteFinalDownloadDir ¶
func (self *FileInfo) DeleteFinalDownloadDir()
type FinalizeFunc ¶
Click to show internal directories.
Click to hide internal directories.