From: Simon Kirsten <1972314+skirsten@users.noreply.github.com> Date: Mon, 11 Oct 2021 00:33:40 +0000 (+0200) Subject: Add DisableInitialPieceCheck option (#677) X-Git-Tag: v1.34.0~7 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=637045c19a5b5fc37c3f7d55f885cee3dab3b5a9;p=btrtrc.git Add DisableInitialPieceCheck option (#677) --- diff --git a/client.go b/client.go index 3cf07cf3..dcf93628 100644 --- a/client.go +++ b/client.go @@ -1195,6 +1195,7 @@ func (t *Torrent) MergeSpec(spec *TorrentSpec) error { if spec.DisplayName != "" { t.SetDisplayName(spec.DisplayName) } + t.initialPieceCheckDisabled = spec.DisableInitialPieceCheck if spec.InfoBytes != nil { err := t.SetInfoBytes(spec.InfoBytes) if err != nil { diff --git a/spec.go b/spec.go index 6708db90..21058477 100644 --- a/spec.go +++ b/spec.go @@ -23,8 +23,9 @@ type TorrentSpec struct { Sources []string // The chunk size to use for outbound requests. Defaults to 16KiB if not set. - ChunkSize int - Storage storage.ClientImpl + ChunkSize int + DisableInitialPieceCheck bool + Storage storage.ClientImpl // Whether to allow data download or upload DisallowDataUpload bool diff --git a/torrent.go b/torrent.go index 3c6a65d9..49d69fe7 100644 --- a/torrent.go +++ b/torrent.go @@ -135,8 +135,9 @@ type Torrent struct { // A cache of completed piece indices. _completedPieces roaring.Bitmap // Pieces that need to be hashed. - piecesQueuedForHash bitmap.Bitmap - activePieceHashes int + piecesQueuedForHash bitmap.Bitmap + activePieceHashes int + initialPieceCheckDisabled bool // A pool of piece priorities []int for assignment to new connections. // These "inclinations" are used to give connections preference for @@ -439,7 +440,7 @@ func (t *Torrent) onSetInfo() { } p.availability = int64(t.pieceAvailabilityFromPeers(i)) t.updatePieceCompletion(pieceIndex(i)) - if !p.storageCompletionOk { + if !t.initialPieceCheckDisabled && !p.storageCompletionOk { // t.logger.Printf("piece %s completion unknown, queueing check", p) t.queuePieceCheck(pieceIndex(i)) }