thinking about timeout
This commit is contained in:
@@ -72,7 +72,7 @@ func MainApp(configPath string) {
|
||||
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)
|
||||
downloader := universal.NewDownloader(downloadClient, config.GetRealDebridTimeout())
|
||||
|
||||
router := chi.NewRouter()
|
||||
handlers.AttachHandlers(router, downloader, torrentMgr, config, rd, log.Named("router"))
|
||||
|
||||
@@ -14,11 +14,15 @@ import (
|
||||
)
|
||||
|
||||
type Downloader struct {
|
||||
client *zurghttp.HTTPClient
|
||||
client *zurghttp.HTTPClient
|
||||
timeoutSecs int
|
||||
}
|
||||
|
||||
func NewDownloader(client *zurghttp.HTTPClient) *Downloader {
|
||||
return &Downloader{client: client}
|
||||
func NewDownloader(client *zurghttp.HTTPClient, timeoutSecs int) *Downloader {
|
||||
return &Downloader{
|
||||
client: client,
|
||||
timeoutSecs: timeoutSecs,
|
||||
}
|
||||
}
|
||||
|
||||
// DownloadFile handles a GET request for files in torrents
|
||||
@@ -162,7 +166,12 @@ func (dl *Downloader) streamFileToResponse(torrent *intTor.Torrent, file *intTor
|
||||
log.Debugf("Downloading unrestricted link %s (%s)%s", unrestrict.Download, unrestrict.Link, rangeLog)
|
||||
}
|
||||
|
||||
// timeout := time.Duration(dl.timeoutSecs) * time.Second
|
||||
// ctx, cancel := context.WithTimeout(context.TODO(), timeout)
|
||||
// dlReq = dlReq.WithContext(ctx)
|
||||
|
||||
download, err := dl.client.Do(dlReq)
|
||||
|
||||
if err != nil {
|
||||
log.Warnf("Cannot download file %s: %v", unrestrict.Download, err)
|
||||
if file != nil && unrestrict.Streamable == 1 {
|
||||
|
||||
Reference in New Issue
Block a user