Skip to content

Commit

Permalink
feat(add): make sleep time configurable (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
brw authored Apr 5, 2024
1 parent f46c1b5 commit 7295702
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cmd/torrent_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func RunTorrentAdd() *cobra.Command {
ignoreRules bool
uploadLimit uint64
downloadLimit uint64
sleep time.Duration
)

var command = &cobra.Command{
Expand Down Expand Up @@ -58,6 +59,7 @@ func RunTorrentAdd() *cobra.Command {
command.Flags().StringVar(&category, "category", "", "Add torrent to the specified category")
command.Flags().Uint64Var(&uploadLimit, "limit-ul", 0, "Set torrent upload speed limit. Unit in bytes/second")
command.Flags().Uint64Var(&downloadLimit, "limit-dl", 0, "Set torrent download speed limit. Unit in bytes/second")
command.Flags().DurationVar(&sleep, "sleep", 200*time.Millisecond, "Set the amount of time to wait between adding torrents in seconds")
command.Flags().StringArrayVar(&tags, "tags", []string{}, "Add tags to torrent")

command.Run = func(cmd *cobra.Command, args []string) {
Expand Down Expand Up @@ -201,9 +203,9 @@ func RunTorrentAdd() *cobra.Command {
log.Printf("successfully added torrent: %s\n", hash)

if len(files) > 1 {
log.Println("sleeping 2 seconds before adding next torrent...")
log.Printf("sleeping %v before adding next torrent...\n", sleep)

time.Sleep(2 * time.Second)
time.Sleep(sleep)

continue
}
Expand Down

0 comments on commit 7295702

Please sign in to comment.