]> Sergey Matveev's repositories - btrtrc.git/blobdiff - misc.go
cmd/btrtrc client
[btrtrc.git] / misc.go
diff --git a/misc.go b/misc.go
index 42c516f0ea5568c3a1f1468e0737923fee6e46dc..7d3007ecee74eb92f58eee434dfb9431a86f9098 100644 (file)
--- a/misc.go
+++ b/misc.go
@@ -93,9 +93,7 @@ func validateInfo(info *metainfo.Info) error {
                if info.TotalLength() != 0 {
                        return errors.New("zero piece length")
                }
-       } else if !info.HasV2() {
-               // TotalLength returns different values for V1 and V2 depending on whether v1 pad files are
-               // counted. Split the interface into several methods?
+       } else {
                if int((info.TotalLength()+info.PieceLength-1)/info.PieceLength) != info.NumPieces() {
                        return errors.New("piece count and file lengths are at odds")
                }
@@ -157,6 +155,16 @@ func maxInt(as ...int) int {
        return ret
 }
 
+func min(as ...int64) int64 {
+       ret := as[0]
+       for _, a := range as[1:] {
+               if a < ret {
+                       ret = a
+               }
+       }
+       return ret
+}
+
 func minInt(as ...int) int {
        ret := as[0]
        for _, a := range as[1:] {