List broken files but dont serve them

This commit is contained in:
Ben Adrian Sarmiento
2024-06-26 10:44:16 +02:00
parent e4650a0f0f
commit d5e3665a53
8 changed files with 12 additions and 19 deletions

View File

@@ -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

View File

@@ -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
}