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,12 +2,15 @@ package fs
|
||||
|
||||
import (
|
||||
"context"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"io"
|
||||
|
||||
"github.com/alist-org/alist/v3/internal/driver"
|
||||
"github.com/alist-org/alist/v3/internal/errs"
|
||||
"github.com/alist-org/alist/v3/internal/model"
|
||||
"github.com/alist-org/alist/v3/internal/op"
|
||||
"github.com/alist-org/alist/v3/internal/task"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"io"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// the param named path of functions in this package is a mount path
|
||||
@ -168,3 +171,19 @@ func Other(ctx context.Context, args model.FsOtherArgs) (interface{}, error) {
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
|
||||
func PutURL(ctx context.Context, path, dstName, urlStr string) error {
|
||||
storage, dstDirActualPath, err := op.GetStorageAndActualPath(path)
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "failed get storage")
|
||||
}
|
||||
if storage.Config().NoUpload {
|
||||
return errors.WithStack(errs.UploadNotSupported)
|
||||
}
|
||||
_, ok := storage.(driver.PutURL)
|
||||
_, okResult := storage.(driver.PutURLResult)
|
||||
if !ok && !okResult {
|
||||
return errs.NotImplement
|
||||
}
|
||||
return op.PutURL(ctx, storage, dstDirActualPath, dstName, urlStr)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ func getArchiveMeta(ctx context.Context, storage driver.Driver, path string, arg
|
||||
meta, err := storageAr.GetArchiveMeta(ctx, obj, args.ArchiveArgs)
|
||||
if !errors.Is(err, errs.NotImplement) {
|
||||
archiveMetaProvider := &model.ArchiveMetaProvider{ArchiveMeta: meta, DriverProviding: true}
|
||||
if meta.GetTree() != nil {
|
||||
if meta != nil && meta.GetTree() != nil {
|
||||
archiveMetaProvider.Sort = &storage.GetStorage().Sort
|
||||
}
|
||||
if !storage.Config().NoCache {
|
||||
|
Reference in New Issue
Block a user