client.go | 1 + spec.go | 5 +++-- torrent.go | 7 ++++--- diff --git a/client.go b/client.go index 3cf07cf337db3a6618486189fdeb309c751f58bf..dcf93628e631d4bd4e48a15cb0d1b6862b13acc9 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 6708db9093ce6420c73bd5312ee067944a3f578f..21058477e30d28658dc997b5719a8b2d2210fb28 100644 --- a/spec.go +++ b/spec.go @@ -23,8 +23,9 @@ // The combination of the "xs" and "as" fields in magnet links, for now. 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 3c6a65d9ab627cc87ae171c8114d7ea424c01743..49d69fe7bab6190ccb586d6afe5bcb5f548be1d6 100644 --- a/torrent.go +++ b/torrent.go @@ -135,8 +135,9 @@ _pendingPieces prioritybitmap.PriorityBitmap // 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 @@ panic(p.availability) } 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)) }