feat(alias): support writing to non-ambiguous paths (#8216)
* feat(alias): support writing to non-ambiguous paths * feat(alias): support extract concurrency * fix(alias): extract url no pass query
This commit is contained in:
@ -2,20 +2,20 @@ package tool
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/url"
|
||||
stdpath "path"
|
||||
"path/filepath"
|
||||
|
||||
_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"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/alist-org/alist/v3/internal/conf"
|
||||
"github.com/alist-org/alist/v3/internal/errs"
|
||||
"github.com/alist-org/alist/v3/internal/fs"
|
||||
"github.com/alist-org/alist/v3/internal/model"
|
||||
"github.com/alist-org/alist/v3/internal/op"
|
||||
"github.com/alist-org/alist/v3/internal/setting"
|
||||
"github.com/alist-org/alist/v3/internal/task"
|
||||
"github.com/google/uuid"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
@ -59,8 +59,11 @@ func AddURL(ctx context.Context, args *AddURLArgs) (task.TaskExtensionInfo, erro
|
||||
}
|
||||
}
|
||||
// try putting url
|
||||
if args.Tool == "SimpleHttp" && tryPutUrl(ctx, storage, dstDirActualPath, args.URL) {
|
||||
return nil, nil
|
||||
if args.Tool == "SimpleHttp" {
|
||||
err = tryPutUrl(ctx, args.DstDirPath, args.URL)
|
||||
if err == nil || !errors.Is(err, errs.NotImplement) {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// get tool
|
||||
@ -118,17 +121,13 @@ func AddURL(ctx context.Context, args *AddURLArgs) (task.TaskExtensionInfo, erro
|
||||
return t, nil
|
||||
}
|
||||
|
||||
func tryPutUrl(ctx context.Context, storage driver.Driver, dstDirActualPath, urlStr string) bool {
|
||||
_, ok := storage.(driver.PutURL)
|
||||
_, okResult := storage.(driver.PutURLResult)
|
||||
if !ok && !okResult {
|
||||
return false
|
||||
}
|
||||
func tryPutUrl(ctx context.Context, path, urlStr string) error {
|
||||
var dstName string
|
||||
u, err := url.Parse(urlStr)
|
||||
if err != nil {
|
||||
return false
|
||||
if err == nil {
|
||||
dstName = stdpath.Base(u.Path)
|
||||
} else {
|
||||
dstName = "UnnamedURL"
|
||||
}
|
||||
dstName := path.Base(u.Path)
|
||||
err = op.PutURL(ctx, storage, dstDirActualPath, dstName, urlStr)
|
||||
return err == nil
|
||||
return fs.PutURL(ctx, path, dstName, urlStr)
|
||||
}
|
||||
|
Reference in New Issue
Block a user