Catch download error case
This commit is contained in:
@@ -64,7 +64,7 @@ func (dl *Downloader) DownloadFile(
|
||||
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")
|
||||
http.Error(resp, "File is not available", http.StatusLocked)
|
||||
http.Error(resp, "File is not available (bandwidth limit reached)", http.StatusLocked)
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
@@ -108,7 +108,7 @@ func (dl *Downloader) DownloadLink(
|
||||
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")
|
||||
http.Error(resp, "Link is not available", http.StatusLocked)
|
||||
http.Error(resp, "Link is not available (bandwidth limit reached)", http.StatusLocked)
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
@@ -151,6 +151,11 @@ 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")
|
||||
http.Error(resp, "File is not available (bandwidth limit reached)", http.StatusLocked)
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
log.Warnf("Cannot download file %s: %v", unrestrict.Download, err)
|
||||
if file != nil && file.State.Event(context.Background(), "break_file") == nil {
|
||||
|
||||
Reference in New Issue
Block a user