feat(offline-download): allow using offline download tools in any storage (#7716)
* Feat(offline-download): allow using thunder offline download tool in any storage * Feat(offline-download): allow using 115 offline download tool in any storage * Feat(offline-download): allow using pikpak offline download tool in any storage * style(offline-download): unify offline download tool names * feat(offline-download): show available offline download tools only * Fix(offline-download): update unmodified tool names. --------- Co-authored-by: Andy Hsu <i@nn.ci>
This commit is contained in:
@ -2,8 +2,12 @@ package tool
|
||||
|
||||
import (
|
||||
"context"
|
||||
_115 "github.com/alist-org/alist/v3/drivers/115"
|
||||
"github.com/alist-org/alist/v3/drivers/pikpak"
|
||||
"github.com/alist-org/alist/v3/drivers/thunder"
|
||||
"github.com/alist-org/alist/v3/internal/driver"
|
||||
"github.com/alist-org/alist/v3/internal/model"
|
||||
"github.com/alist-org/alist/v3/internal/setting"
|
||||
"github.com/alist-org/alist/v3/internal/task"
|
||||
"net/url"
|
||||
"path"
|
||||
@ -76,19 +80,26 @@ func AddURL(ctx context.Context, args *AddURLArgs) (task.TaskExtensionInfo, erro
|
||||
tempDir := filepath.Join(conf.Conf.TempDir, args.Tool, uid)
|
||||
deletePolicy := args.DeletePolicy
|
||||
|
||||
// 如果当前 storage 是对应网盘,则直接下载到目标路径,无需转存
|
||||
switch args.Tool {
|
||||
case "115 Cloud":
|
||||
tempDir = args.DstDirPath
|
||||
// 防止将下载好的文件删除
|
||||
deletePolicy = DeleteNever
|
||||
case "pikpak":
|
||||
tempDir = args.DstDirPath
|
||||
// 防止将下载好的文件删除
|
||||
deletePolicy = DeleteNever
|
||||
case "thunder":
|
||||
tempDir = args.DstDirPath
|
||||
// 防止将下载好的文件删除
|
||||
deletePolicy = DeleteNever
|
||||
if _, ok := storage.(*_115.Pan115); ok {
|
||||
tempDir = args.DstDirPath
|
||||
} else {
|
||||
tempDir = filepath.Join(setting.GetStr(conf.Pan115TempDir), uid)
|
||||
}
|
||||
case "PikPak":
|
||||
if _, ok := storage.(*pikpak.PikPak); ok {
|
||||
tempDir = args.DstDirPath
|
||||
} else {
|
||||
tempDir = filepath.Join(setting.GetStr(conf.PikPakTempDir), uid)
|
||||
}
|
||||
case "Thunder":
|
||||
if _, ok := storage.(*thunder.Thunder); ok {
|
||||
tempDir = args.DstDirPath
|
||||
} else {
|
||||
tempDir = filepath.Join(setting.GetStr(conf.ThunderTempDir), uid)
|
||||
}
|
||||
}
|
||||
|
||||
taskCreator, _ := ctx.Value("user").(*model.User) // taskCreator is nil when convert failed
|
||||
|
Reference in New Issue
Block a user