Skip to content

Commit

Permalink
Merge pull request #5 from ludviglundgren/fix/options
Browse files Browse the repository at this point in the history
Fix: Change how options are set
  • Loading branch information
ludviglundgren authored Jan 23, 2021
2 parents e7037d4 + 6188f3b commit 6a27e7d
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions cmd/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,15 @@ func v1Add(filePath string, paused bool, label string, path string) error {
log.Fatalf("could not encode file: %v", err)
}

options := delugeClient.Options{
AddPaused: &paused,
DownloadLocation: &path,
// set options
options := delugeClient.Options{}

if paused {
options.AddPaused = &paused
}

if path != "" {
options.DownloadLocation = &path
}

torrentHash, err := deluge.AddTorrentFile(filePath, encodedFile, &options)
Expand Down Expand Up @@ -168,9 +174,15 @@ func v2Add(filePath string, paused bool, label string, path string) error {
log.Fatalf("could not encode file: %v", err)
}

options := delugeClient.Options{
AddPaused: &paused,
DownloadLocation: &path,
// set options
options := delugeClient.Options{}

if paused {
options.AddPaused = &paused
}

if path != "" {
options.DownloadLocation = &path
}

torrentHash, err := deluge.AddTorrentFile(filePath, encodedFile, &options)
Expand Down

0 comments on commit 6a27e7d

Please sign in to comment.