aboutsummaryrefslogtreecommitdiff
path: root/meta/torrent.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-06-12 21:29:54 +0200
committerDimitri Sokolyuk <demon@dim13.org>2016-06-12 21:29:54 +0200
commit6210722bbf16bdc671bc1331e0e929c4335cf9af (patch)
tree772e2a531f2bc201ffe37eee10a11ecd1eb6ef35 /meta/torrent.go
parente0c077f328c0880cb8326de4f7718aaeae140796 (diff)
typo
Diffstat (limited to 'meta/torrent.go')
-rw-r--r--meta/torrent.go16
1 files changed, 6 insertions, 10 deletions
diff --git a/meta/torrent.go b/meta/torrent.go
index 358ed01..656e2c9 100644
--- a/meta/torrent.go
+++ b/meta/torrent.go
@@ -26,13 +26,9 @@ func (i Info) SingleFile() bool {
return len(i.Files) > 0
}
-// returns pieceCoung and size of last piece
-func (i Info) pieceCount() int {
- n := i.Length / i.PieceLength
- if i.Length%i.PieceLength > 0 {
- n++
- }
- return n
+// PieceCopunt returns count of full pieces and size of last piece
+func (i Info) PieceCount() (int, int) {
+ return i.Length / i.PieceLength, i.Length % i.PieceLength
}
func (i Info) String() string {
@@ -44,9 +40,9 @@ func (i Info) String() string {
i.Length += f.Length
}
}
- s += fmt.Sprintf("%s (%d)\n", i.Name, i.Length)
- s += fmt.Sprintf("chunks: %d × %d + %d\n",
- i.Length/i.PieceLength, i.PieceLength, i.Length%i.PieceLength)
+ s += fmt.Sprintf("%s (%d) ", i.Name, i.Length)
+ full, last := i.PieceCount()
+ s += fmt.Sprintf("%d × %d + %d\n", full, i.PieceLength, last)
return s
}