aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--meta/info.go13
1 files changed, 6 insertions, 7 deletions
diff --git a/meta/info.go b/meta/info.go
index aa5a414..988c3bc 100644
--- a/meta/info.go
+++ b/meta/info.go
@@ -21,14 +21,13 @@ type Info struct {
RootHash []byte `bencode:"root hash"` // BEP-0030
}
-func (i Info) TotalLength() (l int) {
- if i.Length > 0 {
- return i.Length
- }
- for _, f := range i.Files {
- l += f.Length
+func (i Info) TotalLength() int {
+ if i.Length == 0 {
+ for _, f := range i.Files {
+ i.Length += f.Length
+ }
}
- return
+ return i.Length
}
func (i Info) GetPieces() []Piece {