From 240b42fd56174436a8c1bec229328be10a8fb29e Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Sat, 9 Jul 2022 14:06:27 +1000 Subject: [PATCH] cmd/torrent create: Add piece length and private options --- cmd/torrent/create.go | 10 ++++++++-- go.mod | 2 +- go.sum | 4 ++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cmd/torrent/create.go b/cmd/torrent/create.go index d8681e8e..8f4440c4 100644 --- a/cmd/torrent/create.go +++ b/cmd/torrent/create.go @@ -2,6 +2,7 @@ package main import ( "github.com/anacrolix/bargle" + "github.com/anacrolix/tagflag" "github.com/anacrolix/torrent/bencode" "github.com/anacrolix/torrent/metainfo" "os" @@ -20,8 +21,10 @@ func create() (cmd bargle.Command) { Comment string `name:"t" help:"comment"` CreatedBy string `name:"c" help:"created by"` InfoName *string `name:"i" help:"override info name (defaults to ROOT)"` + PieceLength tagflag.Bytes Url []string `name:"u" help:"add webseed url"` - Root string `arg:"positional"` + Private *bool + Root string `arg:"positional"` } cmd = bargle.FromStruct(&args) cmd.Desc = "Creates a torrent metainfo for the file system rooted at ROOT, and outputs it to stdout" @@ -43,7 +46,10 @@ func create() (cmd bargle.Command) { mi.CreatedBy = args.CreatedBy } mi.UrlList = args.Url - info := metainfo.Info{} + info := metainfo.Info{ + PieceLength: args.PieceLength.Int64(), + Private: args.Private, + } err = info.BuildFromFilePath(args.Root) if err != nil { return diff --git a/go.mod b/go.mod index 74bb792d..8e351f99 100644 --- a/go.mod +++ b/go.mod @@ -51,7 +51,7 @@ require ( require ( github.com/alecthomas/atomic v0.1.0-alpha2 // indirect github.com/alexflint/go-scalar v1.1.0 // indirect - github.com/anacrolix/bargle v0.0.0-20220622082028-6c0bfc8b614d // indirect + github.com/anacrolix/bargle v0.0.0-20220630015206-d7a4d433886a // indirect github.com/anacrolix/mmsg v1.0.0 // indirect github.com/anacrolix/stm v0.4.0 // indirect github.com/benbjohnson/immutable v0.3.0 // indirect diff --git a/go.sum b/go.sum index 06acff1f..b936cbe3 100644 --- a/go.sum +++ b/go.sum @@ -68,6 +68,10 @@ github.com/anacrolix/bargle v0.0.0-20220620083758-c3885e1796d1 h1:RijTNFCxug0EBO github.com/anacrolix/bargle v0.0.0-20220620083758-c3885e1796d1/go.mod h1:cC/kX8wL4i1n+63lOrXhPQQlsoxCo0EqV88fGExQwcY= github.com/anacrolix/bargle v0.0.0-20220622082028-6c0bfc8b614d h1:eSBxjJUsa4p5lCn8mlp6gOdzhZYZxqr4YHPk8Uwn1iQ= github.com/anacrolix/bargle v0.0.0-20220622082028-6c0bfc8b614d/go.mod h1:9xUiZbkh+94FbiIAL1HXpAIBa832f3Mp07rRPl5c5RQ= +github.com/anacrolix/bargle v0.0.0-20220627055849-08d7fa720ece h1:QPZd4ViWNy2uxIbrj1fIhvLxpe27GrnzaaVHGfY6Aac= +github.com/anacrolix/bargle v0.0.0-20220627055849-08d7fa720ece/go.mod h1:9xUiZbkh+94FbiIAL1HXpAIBa832f3Mp07rRPl5c5RQ= +github.com/anacrolix/bargle v0.0.0-20220630015206-d7a4d433886a h1:KCP9QvHlLoUQBOaTf/YCuOzG91Ym1cPB6S68O4Q3puo= +github.com/anacrolix/bargle v0.0.0-20220630015206-d7a4d433886a/go.mod h1:9xUiZbkh+94FbiIAL1HXpAIBa832f3Mp07rRPl5c5RQ= github.com/anacrolix/chansync v0.3.0 h1:lRu9tbeuw3wl+PhMu/r+JJCRu5ArFXIluOgdF0ao6/U= github.com/anacrolix/chansync v0.3.0/go.mod h1:DZsatdsdXxD0WiwcGl0nJVwyjCKMDv+knl1q2iBjA2k= github.com/anacrolix/dht/v2 v2.18.0 h1:btjVjzjKqO5nKGbJHJ2UmuwiRx+EgX3e+OCHC9+WRz8=