Fix rewrites

This commit is contained in:
Ben Sarmiento
2024-05-22 02:26:20 +02:00
parent a9cc689702
commit 9990bf90ca
10 changed files with 149 additions and 114 deletions

View File

@@ -63,8 +63,7 @@ func (dl *Downloader) DownloadFile(
unrestrict := torMgr.UnrestrictFileUntilOk(file)
if unrestrict == nil {
err := file.State.Event(context.Background(), "break_file")
if err != nil {
if err := file.State.Event(context.Background(), "break_file"); err != nil {
log.Errorf("File %s is stale: %v", fileName, err)
http.Error(resp, "File is stale, please try again", http.StatusLocked)
return
@@ -154,8 +153,7 @@ func (dl *Downloader) streamFileToResponse(
downloadResp, err := dl.client.Do(dlReq)
if err != nil {
if file != nil && unrestrict.Streamable == 1 {
err := file.State.Event(context.Background(), "break_file")
if err != nil {
if err := file.State.Event(context.Background(), "break_file"); err != nil {
log.Errorf("File %s is stale: %v", file.Path, err)
http.Error(resp, "File is stale, please try again", http.StatusLocked)
return
@@ -177,8 +175,7 @@ func (dl *Downloader) streamFileToResponse(
// Check if the download was not successful
if downloadResp.StatusCode/100 != 2 {
if file != nil && unrestrict.Streamable == 1 {
err := file.State.Event(context.Background(), "break_file")
if err != nil {
if err := file.State.Event(context.Background(), "break_file"); err != nil {
log.Errorf("File %s is stale: %v", file.Path, err)
http.Error(resp, "File is stale, please try again", http.StatusLocked)
return