aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-07-06 21:01:16 +0200
committerDimitri Sokolyuk <demon@dim13.org>2016-07-06 21:01:16 +0200
commitd674b9a758cb154972c372e630a66b2fcfdaaa3a (patch)
tree547bbdea264402bc0c0c8ee2bc051b92ea7ce834
parent4725f9ee0659b91116bcecca4ba036a2c377cf48 (diff)
cleanup
-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 {