]> Sergey Matveev's repositories - btrtrc.git/blobdiff - file.go
cmd/btrtrc client
[btrtrc.git] / file.go
diff --git a/file.go b/file.go
index 3a53adaa461f2d99fcde2c643813f48130fac91e..2ff474426d62ac1b3bf8a72616ad7a8ee7cce04b 100644 (file)
--- a/file.go
+++ b/file.go
@@ -2,6 +2,7 @@ package torrent
 
 import (
        "crypto/sha256"
+
        "github.com/RoaringBitmap/roaring"
        g "github.com/anacrolix/generics"
        "github.com/anacrolix/missinggo/v2/bitmap"
@@ -17,7 +18,7 @@ type File struct {
        length      int64
        fi          metainfo.FileInfo
        displayPath string
-       prio        piecePriority
+       prio        PiecePriority
        piecesRoot  g.Option[[sha256.Size]byte]
 }
 
@@ -118,9 +119,17 @@ func fileBytesLeft(
 }
 
 func (f *File) bytesLeft() (left int64) {
-       return fileBytesLeft(int64(f.t.usualPieceSize()), f.BeginPieceIndex(), f.EndPieceIndex(), f.offset, f.length, &f.t._completedPieces, func(pieceIndex int) int64 {
-               return int64(f.t.piece(pieceIndex).numDirtyBytes())
-       })
+       return fileBytesLeft(
+               int64(f.t.usualPieceSize()),
+               f.BeginPieceIndex(),
+               f.EndPieceIndex(),
+               f.offset,
+               f.length,
+               &f.t._completedPieces,
+               func(pieceIndex int) int64 {
+                       return int64(f.t.piece(pieceIndex).numDirtyBytes())
+               },
+       )
 }
 
 // The relative file path for a multi-file torrent, and the torrent name for a
@@ -179,7 +188,7 @@ func (f *File) NewReader() Reader {
 }
 
 // Sets the minimum priority for pieces in the File.
-func (f *File) SetPriority(prio piecePriority) {
+func (f *File) SetPriority(prio PiecePriority) {
        f.t.cl.lock()
        if prio != f.prio {
                f.prio = prio
@@ -189,7 +198,7 @@ func (f *File) SetPriority(prio piecePriority) {
 }
 
 // Returns the priority per File.SetPriority.
-func (f *File) Priority() (prio piecePriority) {
+func (f *File) Priority() (prio PiecePriority) {
        f.t.cl.rLock()
        prio = f.prio
        f.t.cl.rUnlock()