]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Add DisableInitialPieceCheck option (#677)
authorSimon Kirsten <1972314+skirsten@users.noreply.github.com>
Mon, 11 Oct 2021 00:33:40 +0000 (02:33 +0200)
committerGitHub <noreply@github.com>
Mon, 11 Oct 2021 00:33:40 +0000 (11:33 +1100)
client.go
spec.go
torrent.go

index 3cf07cf337db3a6618486189fdeb309c751f58bf..dcf93628e631d4bd4e48a15cb0d1b6862b13acc9 100644 (file)
--- 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 (file)
--- 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
index 3c6a65d9ab627cc87ae171c8114d7ea424c01743..49d69fe7bab6190ccb586d6afe5bcb5f548be1d6 100644 (file)
@@ -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))
                }