mirror of https://github.com/cloudreve/Cloudreve
fix(remote download): slave canceled task error is not passed to master in non-debug mode (#2301)
parent
2333ed3501
commit
a0b4c97db0
|
@ -5,7 +5,6 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/cloudflare/cfssl/scan/crypto/sha1"
|
||||
"github.com/cloudreve/Cloudreve/v4/application/constants"
|
||||
|
@ -95,7 +94,7 @@ func (s *slaveDownloader) Info(ctx context.Context, handle *downloader.TaskHandl
|
|||
// 处理列取结果
|
||||
if resp.Code != 0 {
|
||||
err = serializer.NewErrorFromResponse(resp)
|
||||
if strings.Contains(err.Error(), downloader.ErrTaskNotFount.Error()) {
|
||||
if resp.Code == serializer.CodeNotFound {
|
||||
return nil, fmt.Errorf("%s (%w)", err.Error(), downloader.ErrTaskNotFount)
|
||||
}
|
||||
return nil, err
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package controllers
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/cloudreve/Cloudreve/v4/pkg/cluster"
|
||||
|
@ -146,6 +147,12 @@ func SlaveDownloadTaskStatus(c *gin.Context) {
|
|||
d := c.MustGet(downloader.DownloaderCtxKey).(downloader.Downloader)
|
||||
info, err := d.Info(c, service.Handle)
|
||||
if err != nil {
|
||||
if errors.Is(err, downloader.ErrTaskNotFount) {
|
||||
c.JSON(200, serializer.NewError(serializer.CodeNotFound, "task not found", err))
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(200, serializer.Err(c, err))
|
||||
c.Abort()
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue