Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to configure download directory #54

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type Client struct {
// ClientConfig specifies the behaviour of a client.
type ClientConfig struct {
TorrentPath string
DataDir string
Port int
TorrentPort int
Seed bool
Expand Down Expand Up @@ -74,7 +75,7 @@ func NewClient(cfg ClientConfig) (client Client, err error) {

blocklist := getBlocklist()
torrentConfig := torrent.NewDefaultClientConfig()
torrentConfig.DataDir = os.TempDir()
torrentConfig.DataDir = cfg.DataDir
torrentConfig.NoUpload = !cfg.Seed
torrentConfig.DisableTCP = !cfg.TCP
torrentConfig.ListenPort = cfg.TorrentPort
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func main() {
flag.BoolVar(&cfg.Seed, "seed", cfg.Seed, "Seed after finished downloading")
flag.IntVar(&cfg.MaxConnections, "conn", cfg.MaxConnections, "Maximum number of connections")
flag.BoolVar(&cfg.TCP, "tcp", cfg.TCP, "Allow connections via TCP")
flag.StringVar(&cfg.DataDir, "datadir", os.TempDir(), "Where to download torrent data")
flag.Parse()
if len(flag.Args()) == 0 {
flag.Usage()
Expand Down