List broken files but dont serve them
This commit is contained in:
@@ -32,6 +32,7 @@ func CheckFile(directory, torrentName, fileName string, w http.ResponseWriter, r
|
||||
http.Error(w, "File not found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
contentType := getContentMimeType(fileName)
|
||||
contentLength := fmt.Sprintf("%d", file.Bytes)
|
||||
lastModified := file.Ended
|
||||
|
||||
@@ -87,14 +87,9 @@ func (dl *Downloader) DownloadFile(
|
||||
return
|
||||
}
|
||||
|
||||
if !file.State.Is("ok_file") {
|
||||
http.Error(resp, "File is not available", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
unrestrict, err := torMgr.UnrestrictFile(file, cfg.ShouldServeFromRclone())
|
||||
if dlErr, ok := err.(*zurghttp.DownloadErrorResponse); ok && dlErr.Message == "bytes_limit_reached" {
|
||||
log.Warnf("Your account has reached the bandwidth limit, please try again after 12AM CET")
|
||||
// log.Warnf("Your account has reached the bandwidth limit, please try again after 12AM CET")
|
||||
http.Error(resp, "File is not available (bandwidth limit reached)", http.StatusLocked)
|
||||
return
|
||||
}
|
||||
@@ -138,7 +133,7 @@ func (dl *Downloader) DownloadLink(
|
||||
// log.Debugf("Opening file %s (%s)", fileName, link)
|
||||
unrestrict, err := torMgr.UnrestrictLink(link, cfg.ShouldServeFromRclone())
|
||||
if dlErr, ok := err.(*zurghttp.DownloadErrorResponse); ok && dlErr.Message == "bytes_limit_reached" {
|
||||
log.Warnf("Your account has reached the bandwidth limit, please try again after 12AM CET")
|
||||
// log.Warnf("Your account has reached the bandwidth limit, please try again after 12AM CET")
|
||||
http.Error(resp, "Link is not available (bandwidth limit reached)", http.StatusLocked)
|
||||
return
|
||||
}
|
||||
@@ -183,7 +178,7 @@ func (dl *Downloader) streamFileToResponse(
|
||||
// Perform the request
|
||||
downloadResp, err := dl.client.Do(dlReq)
|
||||
if dlErr, ok := err.(*zurghttp.DownloadErrorResponse); ok && dlErr.Message == "bytes_limit_reached" {
|
||||
log.Warnf("Your account has reached the bandwidth limit, please try again after 12AM CET")
|
||||
// log.Warnf("Your account has reached the bandwidth limit, please try again after 12AM CET")
|
||||
http.Error(resp, "File is not available (bandwidth limit reached)", http.StatusLocked)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user