Catch download error case
This commit is contained in:
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@@ -5,7 +5,7 @@ on:
|
|||||||
tags:
|
tags:
|
||||||
- 'v**'
|
- 'v**'
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 0 * * *'
|
- cron: '0 1 * * *'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@@ -38,7 +38,7 @@ jobs:
|
|||||||
continue-on-error: false
|
continue-on-error: false
|
||||||
run: |
|
run: |
|
||||||
# 3AM CET
|
# 3AM CET
|
||||||
since="$(date -d 'yesterday' +%Y-%m-%d) 00:00:00"
|
since="$(date -d 'yesterday' +%Y-%m-%d) 01:00:00"
|
||||||
count=$(git rev-list --count --since="$since" --until=now HEAD)
|
count=$(git rev-list --count --since="$since" --until=now HEAD)
|
||||||
if [ "$count" -gt 0 ]; then
|
if [ "$count" -gt 0 ]; then
|
||||||
echo "new_commits=true" >> $GITHUB_OUTPUT
|
echo "new_commits=true" >> $GITHUB_OUTPUT
|
||||||
|
|||||||
4
.github/workflows/build_docker.yml
vendored
4
.github/workflows/build_docker.yml
vendored
@@ -5,7 +5,7 @@ on:
|
|||||||
tags:
|
tags:
|
||||||
- 'v**'
|
- 'v**'
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 0 * * *'
|
- cron: '0 1 * * *'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-push-image:
|
build-and-push-image:
|
||||||
@@ -25,7 +25,7 @@ jobs:
|
|||||||
continue-on-error: false
|
continue-on-error: false
|
||||||
run: |
|
run: |
|
||||||
# 3AM CET
|
# 3AM CET
|
||||||
since="$(date -d 'yesterday' +%Y-%m-%d) 00:00:00"
|
since="$(date -d 'yesterday' +%Y-%m-%d) 01:00:00"
|
||||||
count=$(git rev-list --count --since="$since" --until=now HEAD)
|
count=$(git rev-list --count --since="$since" --until=now HEAD)
|
||||||
if [ "$count" -gt 0 ]; then
|
if [ "$count" -gt 0 ]; then
|
||||||
echo "new_commits=true" >> $GITHUB_OUTPUT
|
echo "new_commits=true" >> $GITHUB_OUTPUT
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ func (dl *Downloader) DownloadFile(
|
|||||||
unrestrict, err := torMgr.UnrestrictFile(file, cfg.ShouldServeFromRclone())
|
unrestrict, err := torMgr.UnrestrictFile(file, cfg.ShouldServeFromRclone())
|
||||||
if dlErr, ok := err.(*zurghttp.DownloadErrorResponse); ok && dlErr.Message == "bytes_limit_reached" {
|
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", http.StatusLocked)
|
http.Error(resp, "File is not available (bandwidth limit reached)", http.StatusLocked)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -108,7 +108,7 @@ func (dl *Downloader) DownloadLink(
|
|||||||
unrestrict, err := torMgr.UnrestrictLink(link, cfg.ShouldServeFromRclone())
|
unrestrict, err := torMgr.UnrestrictLink(link, cfg.ShouldServeFromRclone())
|
||||||
if dlErr, ok := err.(*zurghttp.DownloadErrorResponse); ok && dlErr.Message == "bytes_limit_reached" {
|
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", http.StatusLocked)
|
http.Error(resp, "Link is not available (bandwidth limit reached)", http.StatusLocked)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -151,6 +151,11 @@ func (dl *Downloader) streamFileToResponse(
|
|||||||
|
|
||||||
// Perform the request
|
// Perform the request
|
||||||
downloadResp, err := dl.client.Do(dlReq)
|
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 {
|
if err != nil {
|
||||||
log.Warnf("Cannot download file %s: %v", unrestrict.Download, err)
|
log.Warnf("Cannot download file %s: %v", unrestrict.Download, err)
|
||||||
if file != nil && file.State.Event(context.Background(), "break_file") == nil {
|
if file != nil && file.State.Event(context.Background(), "break_file") == nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user