diff --git a/internal/action/qbittorrent.go b/internal/action/qbittorrent.go index 861175f..667019e 100644 --- a/internal/action/qbittorrent.go +++ b/internal/action/qbittorrent.go @@ -2,6 +2,7 @@ package action import ( "context" + "fmt" "github.com/autobrr/autobrr/internal/domain" "github.com/autobrr/autobrr/pkg/errors" @@ -125,18 +126,30 @@ func (s *service) qbittorrentCheckRulesCanDownload(ctx context.Context, action * // if current transfer speed is more than threshold return out and skip // DlInfoSpeed is in bytes so lets convert to KB to match DownloadSpeedThreshold if info.DlInfoSpeed/1024 >= client.Settings.Rules.DownloadSpeedThreshold { - s.log.Debug().Msg("max active downloads reached, skipping") + rejection := fmt.Sprintf("max active downloads reached and total download speed above threshold: %d, skipping", client.Settings.Rules.DownloadSpeedThreshold) - rejections := []string{"max active downloads reached, skipping"} - return rejections, nil + s.log.Debug().Msg(rejection) + + return []string{rejection}, nil + } + + // if current transfer speed is more than threshold return out and skip + // UpInfoSpeed is in bytes so lets convert to KB to match UploadSpeedThreshold + if info.UpInfoSpeed/1024 >= client.Settings.Rules.UploadSpeedThreshold { + rejection := fmt.Sprintf("max active downloads reached and total upload speed above threshold: %d, skipping", client.Settings.Rules.UploadSpeedThreshold) + + s.log.Debug().Msg(rejection) + + return []string{rejection}, nil } s.log.Debug().Msg("active downloads are slower than set limit, lets add it") } else { - s.log.Debug().Msg("max active downloads reached, skipping") + rejection := "max active downloads reached, skipping" - rejections := []string{"max active downloads reached, skipping"} - return rejections, nil + s.log.Debug().Msg(rejection) + + return []string{rejection}, nil } } } diff --git a/internal/domain/client.go b/internal/domain/client.go index 61650ed..60f809f 100644 --- a/internal/domain/client.go +++ b/internal/domain/client.go @@ -48,6 +48,7 @@ type DownloadClientRules struct { MaxActiveDownloads int `json:"max_active_downloads"` IgnoreSlowTorrents bool `json:"ignore_slow_torrents"` DownloadSpeedThreshold int64 `json:"download_speed_threshold"` + UploadSpeedThreshold int64 `json:"upload_speed_threshold"` } type BasicAuth struct { diff --git a/web/src/forms/settings/DownloadClientForms.tsx b/web/src/forms/settings/DownloadClientForms.tsx index 1701f71..686da22 100644 --- a/web/src/forms/settings/DownloadClientForms.tsx +++ b/web/src/forms/settings/DownloadClientForms.tsx @@ -269,12 +269,20 @@ function FormFieldsRules() { /> {settings.rules?.ignore_slow_torrents === true && ( - + <> + + + )} )} diff --git a/web/src/types/Download.d.ts b/web/src/types/Download.d.ts index 69f8961..f74d58a 100644 --- a/web/src/types/Download.d.ts +++ b/web/src/types/Download.d.ts @@ -25,6 +25,7 @@ interface DownloadClientRules { max_active_downloads: number; ignore_slow_torrents: boolean; download_speed_threshold: number; + upload_speed_threshold: number; } interface DownloadClientBasicAuth {