diff --git a/internal/app.go b/internal/app.go index b720cde..50e28a5 100644 --- a/internal/app.go +++ b/internal/app.go @@ -44,7 +44,7 @@ func MainApp(configPath string) { os.Exit(1) } - apiClient := http.NewHTTPClient(config.GetToken(), config.GetRetriesUntilFailed(), config.GetRealDebridTimeout(), false, config, log.Named("httpclient")) + apiClient := http.NewHTTPClient(config.GetToken(), config.GetRetriesUntilFailed(), config.GetApiTimeoutSecs(), false, config, log.Named("httpclient")) rd := realdebrid.NewRealDebrid(apiClient, log.Named("realdebrid")) @@ -71,8 +71,8 @@ func MainApp(configPath string) { utils.EnsureDirExists("data") // Ensure the data directory exists torrentMgr := torrent.NewTorrentManager(config, rd, workerPool, repairPool, log.Named("manager")) - downloadClient := http.NewHTTPClient(config.GetToken(), config.GetRetriesUntilFailed(), 0, true, config, log.Named("dlclient")) - downloader := universal.NewDownloader(downloadClient, config.GetRealDebridTimeout()) + downloadClient := http.NewHTTPClient(config.GetToken(), config.GetRetriesUntilFailed(), config.GetDownloadTimeoutSecs(), true, config, log.Named("dlclient")) + downloader := universal.NewDownloader(downloadClient) router := chi.NewRouter() handlers.AttachHandlers(router, downloader, torrentMgr, config, rd, log.Named("router")) diff --git a/internal/config/types.go b/internal/config/types.go index ef0ccd8..b58121c 100644 --- a/internal/config/types.go +++ b/internal/config/types.go @@ -5,8 +5,8 @@ type ConfigInterface interface { GetVersion() string GetToken() string GetNumOfWorkers() int - GetRefreshEverySeconds() int - GetRepairEveryMinutes() int + GetRefreshEverySecs() int + GetRepairEveryMins() int EnableRepair() bool GetHost() string GetPort() string @@ -23,10 +23,11 @@ type ConfigInterface interface { ShouldServeFromRclone() bool ShouldVerifyDownloadLink() bool ShouldForceIPv6() bool - GetRealDebridTimeout() int + GetApiTimeoutSecs() int + GetDownloadTimeoutSecs() int GetRetriesUntilFailed() int EnableDownloadMount() bool - GetRateLimitSleepSeconds() int + GetRateLimitSleepSecs() int ShouldDeleteRarFiles() bool } @@ -34,14 +35,14 @@ type ZurgConfig struct { Version string `yaml:"zurg" json:"-"` Token string `yaml:"token" json:"-"` - Host string `yaml:"host" json:"host"` - Port string `yaml:"port" json:"port"` - Username string `yaml:"username" json:"username"` - Password string `yaml:"password" json:"password"` - Proxy string `yaml:"proxy" json:"proxy"` - NumOfWorkers int `yaml:"concurrent_workers" json:"concurrent_workers"` - RefreshEverySeconds int `yaml:"check_for_changes_every_secs" json:"check_for_changes_every_secs"` - RepairEveryMins int `yaml:"repair_every_mins" json:"repair_every_mins"` + Host string `yaml:"host" json:"host"` + Port string `yaml:"port" json:"port"` + Username string `yaml:"username" json:"username"` + Password string `yaml:"password" json:"password"` + Proxy string `yaml:"proxy" json:"proxy"` + NumOfWorkers int `yaml:"concurrent_workers" json:"concurrent_workers"` + RefreshEverySecs int `yaml:"check_for_changes_every_secs" json:"check_for_changes_every_secs"` + RepairEveryMins int `yaml:"repair_every_mins" json:"repair_every_mins"` IgnoreRenames bool `yaml:"ignore_renames" json:"ignore_renames"` RetainRDTorrentName bool `yaml:"retain_rd_torrent_name" json:"retain_rd_torrent_name"` @@ -50,14 +51,15 @@ type ZurgConfig struct { CanRepair bool `yaml:"enable_repair" json:"enable_repair"` DeleteRarFiles bool `yaml:"auto_delete_rar_torrents" json:"auto_delete_rar_torrents"` - RealDebridTimeout int `yaml:"realdebrid_timeout_secs" json:"realdebrid_timeout_secs"` - DownloadMount bool `yaml:"enable_download_mount" json:"enable_download_mount"` - RateLimitSleepSeconds int `yaml:"rate_limit_sleep_secs" json:"rate_limit_sleep_secs"` - RetriesUntilFailed int `yaml:"retries_until_failed" json:"retries_until_failed"` - NetworkBufferSize int `yaml:"network_buffer_size" json:"network_buffer_size"` - ServeFromRclone bool `yaml:"serve_from_rclone" json:"serve_from_rclone"` - VerifyDownloadLink bool `yaml:"verify_download_link" json:"verify_download_link"` - ForceIPv6 bool `yaml:"force_ipv6" json:"force_ipv6"` + ApiTimeoutSecs int `yaml:"api_timeout_secs" json:"api_timeout_secs"` + DownloadTimeoutSecs int `yaml:"download_timeout_secs" json:"download_timeout_secs"` + DownloadMount bool `yaml:"enable_download_mount" json:"enable_download_mount"` + RateLimitSleepSecs int `yaml:"rate_limit_sleep_secs" json:"rate_limit_sleep_secs"` + RetriesUntilFailed int `yaml:"retries_until_failed" json:"retries_until_failed"` + NetworkBufferSize int `yaml:"network_buffer_size" json:"network_buffer_size"` + ServeFromRclone bool `yaml:"serve_from_rclone" json:"serve_from_rclone"` + VerifyDownloadLink bool `yaml:"verify_download_link" json:"verify_download_link"` + ForceIPv6 bool `yaml:"force_ipv6" json:"force_ipv6"` OnLibraryUpdate string `yaml:"on_library_update" json:"on_library_update"` } @@ -103,14 +105,14 @@ func (z *ZurgConfig) GetNumOfWorkers() int { return z.NumOfWorkers } -func (z *ZurgConfig) GetRefreshEverySeconds() int { - if z.RefreshEverySeconds == 0 { +func (z *ZurgConfig) GetRefreshEverySecs() int { + if z.RefreshEverySecs == 0 { return 60 } - return z.RefreshEverySeconds + return z.RefreshEverySecs } -func (z *ZurgConfig) GetRepairEveryMinutes() int { +func (z *ZurgConfig) GetRepairEveryMins() int { if z.RepairEveryMins == 0 { return 60 } @@ -167,18 +169,25 @@ func (z *ZurgConfig) EnableDownloadMount() bool { return z.DownloadMount } -func (z *ZurgConfig) GetRealDebridTimeout() int { - if z.RealDebridTimeout == 0 { +func (z *ZurgConfig) GetApiTimeoutSecs() int { + if z.ApiTimeoutSecs == 0 { return 4 } - return z.RealDebridTimeout + return z.ApiTimeoutSecs } -func (z *ZurgConfig) GetRateLimitSleepSeconds() int { - if z.RateLimitSleepSeconds == 0 { +func (z *ZurgConfig) GetDownloadTimeoutSecs() int { + if z.DownloadTimeoutSecs == 0 { + return 2 + } + return z.DownloadTimeoutSecs +} + +func (z *ZurgConfig) GetRateLimitSleepSecs() int { + if z.RateLimitSleepSecs == 0 { return 4 } - return z.RateLimitSleepSeconds + return z.RateLimitSleepSecs } func (z *ZurgConfig) ShouldDeleteRarFiles() bool { diff --git a/internal/handlers/home.go b/internal/handlers/home.go index 124c87c..fbe04c2 100644 --- a/internal/handlers/home.go +++ b/internal/handlers/home.go @@ -179,8 +179,8 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {