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"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/cloudflare/cfssl/scan/crypto/sha1"
|
"github.com/cloudflare/cfssl/scan/crypto/sha1"
|
||||||
"github.com/cloudreve/Cloudreve/v4/application/constants"
|
"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 {
|
if resp.Code != 0 {
|
||||||
err = serializer.NewErrorFromResponse(resp)
|
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, fmt.Errorf("%s (%w)", err.Error(), downloader.ErrTaskNotFount)
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package controllers
|
package controllers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/cloudreve/Cloudreve/v4/pkg/cluster"
|
"github.com/cloudreve/Cloudreve/v4/pkg/cluster"
|
||||||
|
@ -146,6 +147,12 @@ func SlaveDownloadTaskStatus(c *gin.Context) {
|
||||||
d := c.MustGet(downloader.DownloaderCtxKey).(downloader.Downloader)
|
d := c.MustGet(downloader.DownloaderCtxKey).(downloader.Downloader)
|
||||||
info, err := d.Info(c, service.Handle)
|
info, err := d.Info(c, service.Handle)
|
||||||
if err != nil {
|
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.JSON(200, serializer.Err(c, err))
|
||||||
c.Abort()
|
c.Abort()
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue