its the fastest ever
This commit is contained in:
@@ -14,14 +14,12 @@ import (
|
||||
)
|
||||
|
||||
type Downloader struct {
|
||||
client *zurghttp.HTTPClient
|
||||
timeoutSecs int
|
||||
client *zurghttp.HTTPClient
|
||||
}
|
||||
|
||||
func NewDownloader(client *zurghttp.HTTPClient, timeoutSecs int) *Downloader {
|
||||
func NewDownloader(client *zurghttp.HTTPClient) *Downloader {
|
||||
return &Downloader{
|
||||
client: client,
|
||||
timeoutSecs: timeoutSecs,
|
||||
client: client,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +155,6 @@ func (dl *Downloader) streamFileToResponse(torrent *intTor.Torrent, file *intTor
|
||||
if req.Header.Get("Range") != "" {
|
||||
dlReq.Header.Add("Range", req.Header.Get("Range"))
|
||||
rangeLog = " (range: " + req.Header.Get("Range") + ")"
|
||||
|
||||
}
|
||||
|
||||
if torrent != nil {
|
||||
@@ -166,12 +163,7 @@ 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 {
|
||||
@@ -185,7 +177,6 @@ func (dl *Downloader) streamFileToResponse(torrent *intTor.Torrent, file *intTor
|
||||
http.Error(resp, "File is not available", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
defer download.Body.Close()
|
||||
|
||||
if download.StatusCode/100 != 2 {
|
||||
|
||||
Reference in New Issue
Block a user