Check if host works first before assigning random host

This commit is contained in:
Ben Sarmiento
2024-01-27 00:27:28 +01:00
parent 49b524ada6
commit 4bb0234d8f
4 changed files with 32 additions and 36 deletions

View File

@@ -79,7 +79,7 @@ func (dl *Downloader) DownloadFile(directory, torrentName, fileName string, resp
}
if cfg.ShouldServeFromRclone() {
if cfg.ShouldVerifyDownloadLink() {
if !torMgr.Api.CanFetchFirstByte(unrestrict.Download) {
if !dl.client.CanFetchFirstByte(unrestrict.Download) {
log.Warnf("File %s is not available", fileName)
http.Error(resp, "File is not available", http.StatusNotFound)
return
@@ -123,7 +123,7 @@ func (dl *Downloader) DownloadLink(fileName, link string, resp http.ResponseWrit
}
if cfg.ShouldServeFromRclone() {
if cfg.ShouldVerifyDownloadLink() {
if !torMgr.Api.CanFetchFirstByte(unrestrict.Download) {
if !dl.client.CanFetchFirstByte(unrestrict.Download) {
log.Warnf("File %s is not available", fileName)
http.Error(resp, "File is not available", http.StatusNotFound)
return