Verify downloads
This commit is contained in:
@@ -54,9 +54,16 @@ func (gf *GetFile) HandleGetRequest(directory, torrentName, fileName string, res
|
||||
link := file.Link
|
||||
|
||||
if download, exists := torMgr.DownloadCache.Get(link); exists {
|
||||
if cfg.ShouldServeFromRclone() && torMgr.Api.CanFetchFirstByte(download.Download) {
|
||||
redirect(resp, req, download.Download, cfg)
|
||||
return
|
||||
if cfg.ShouldServeFromRclone() {
|
||||
if cfg.ShouldVerifyDownloadLink() {
|
||||
if torMgr.Api.CanFetchFirstByte(download.Download) {
|
||||
redirect(resp, req, download.Download, cfg)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
redirect(resp, req, download.Download, cfg)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
err := gf.streamCachedLinkToResponse(download.Download, resp, req, torMgr, cfg, log)
|
||||
if err == nil {
|
||||
@@ -93,6 +100,13 @@ func (gf *GetFile) HandleGetRequest(directory, torrentName, fileName string, res
|
||||
}
|
||||
torMgr.DownloadCache.Set(link, unrestrict)
|
||||
if cfg.ShouldServeFromRclone() {
|
||||
if cfg.ShouldVerifyDownloadLink() {
|
||||
if !torMgr.Api.CanFetchFirstByte(unrestrict.Download) {
|
||||
log.Warnf("File %s is not available", fileName)
|
||||
http.Error(resp, "File is not available", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
}
|
||||
redirect(resp, req, unrestrict.Download, cfg)
|
||||
} else {
|
||||
gf.streamFileToResponse(torrent, file, unrestrict, resp, req, torMgr, cfg, log)
|
||||
|
||||
Reference in New Issue
Block a user