Merge c877c9156968cbc6a0ab0f6e6b114d9aa392030a into ffa03bfda11aa18bb899afc1f29e8690fcea1036
This commit is contained in:
commit
af75a209c9
@ -5,6 +5,7 @@ import (
|
||||
"errors"
|
||||
stdpath "path"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/alist-org/alist/v3/internal/driver"
|
||||
"github.com/alist-org/alist/v3/internal/errs"
|
||||
@ -94,7 +95,18 @@ func (d *Alias) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([
|
||||
var objs []model.Obj
|
||||
fsArgs := &fs.ListArgs{NoLog: true, Refresh: args.Refresh}
|
||||
for _, dst := range dsts {
|
||||
tmp, err := d.list(ctx, dst, sub, fsArgs)
|
||||
var tmp []model.Obj
|
||||
var err error
|
||||
if d.Timeout > 0 {
|
||||
childCtx, cancel := context.WithTimeout(ctx, time.Duration(d.Timeout)*time.Second)
|
||||
tmp, err = d.list(childCtx, dst, sub, fsArgs)
|
||||
cancel()
|
||||
} else {
|
||||
tmp, err = d.list(ctx, dst, sub, fsArgs)
|
||||
}
|
||||
if errors.Is(err, context.DeadlineExceeded) {
|
||||
continue
|
||||
}
|
||||
if err == nil {
|
||||
objs = append(objs, tmp...)
|
||||
}
|
||||
@ -109,7 +121,18 @@ func (d *Alias) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (
|
||||
return nil, errs.ObjectNotFound
|
||||
}
|
||||
for _, dst := range dsts {
|
||||
link, err := d.link(ctx, dst, sub, args)
|
||||
var link *model.Link
|
||||
var err error
|
||||
if d.Timeout > 0 {
|
||||
childCtx, cancel := context.WithTimeout(ctx, time.Duration(d.Timeout)*time.Second)
|
||||
link, err = d.link(childCtx, dst, sub, args)
|
||||
cancel()
|
||||
if errors.Is(err, context.DeadlineExceeded) {
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
link, err = d.link(ctx, dst, sub, args)
|
||||
}
|
||||
if err == nil {
|
||||
if !args.Redirect && len(link.URL) > 0 {
|
||||
// 正常情况下 多并发 仅支持返回URL的驱动
|
||||
|
@ -14,6 +14,7 @@ type Addition struct {
|
||||
DownloadConcurrency int `json:"download_concurrency" default:"0" required:"false" type:"number" help:"Need to enable proxy"`
|
||||
DownloadPartSize int `json:"download_part_size" default:"0" type:"number" required:"false" help:"Need to enable proxy. Unit: KB"`
|
||||
Writable bool `json:"writable" type:"bool" default:"false"`
|
||||
Timeout int `json:"timeout" default:"0" required:"false" type:"number" help:"0 for no timeout"`
|
||||
}
|
||||
|
||||
var config = driver.Config{
|
||||
|
Loading…
x
Reference in New Issue
Block a user