mirror of
https://github.com/OpenListTeam/OpenList.git
synced 2025-09-21 05:06:10 +08:00
Compare commits
3 Commits
deps/resty
...
v4.0.8
Author | SHA1 | Date | |
---|---|---|---|
92f396df10 | |||
9557834342 | |||
288ba2fcda |
@ -37,10 +37,11 @@ func (d *QuarkOrUC) GetAddition() driver.Additional {
|
|||||||
func (d *QuarkOrUC) Init(ctx context.Context) error {
|
func (d *QuarkOrUC) Init(ctx context.Context) error {
|
||||||
_, err := d.request("/config", http.MethodGet, nil, nil)
|
_, err := d.request("/config", http.MethodGet, nil, nil)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if d.AdditionVersion != 1 {
|
if d.AdditionVersion != 2 {
|
||||||
d.AdditionVersion = 1
|
d.AdditionVersion = 2
|
||||||
if !d.UseTransCodingAddress {
|
if !d.UseTransCodingAddress && len(d.DownProxyUrl) == 0 {
|
||||||
d.WebProxy = true
|
d.WebProxy = true
|
||||||
|
d.WebdavPolicy = "native_proxy"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ type Addition struct {
|
|||||||
Paths string `json:"paths" required:"true" type:"text"`
|
Paths string `json:"paths" required:"true" type:"text"`
|
||||||
SiteUrl string `json:"siteUrl" type:"text" required:"false" help:"The prefix URL of the strm file"`
|
SiteUrl string `json:"siteUrl" type:"text" required:"false" help:"The prefix URL of the strm file"`
|
||||||
FilterFileTypes string `json:"filterFileTypes" type:"text" default:"strm" required:"false" help:"Supports suffix name of strm file"`
|
FilterFileTypes string `json:"filterFileTypes" type:"text" default:"strm" required:"false" help:"Supports suffix name of strm file"`
|
||||||
UseSign bool `json:"signPath" default:"true" required:"true" help:"sign the path in the strm file"`
|
|
||||||
EncodePath bool `json:"encodePath" default:"true" required:"true" help:"encode the path in the strm file"`
|
EncodePath bool `json:"encodePath" default:"true" required:"true" help:"encode the path in the strm file"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,7 +26,6 @@ func init() {
|
|||||||
op.RegisterDriver(func() driver.Driver {
|
op.RegisterDriver(func() driver.Driver {
|
||||||
return &Strm{
|
return &Strm{
|
||||||
Addition: Addition{
|
Addition: Addition{
|
||||||
UseSign: true,
|
|
||||||
EncodePath: true,
|
EncodePath: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ func (d *Strm) getLink(ctx context.Context, path string) string {
|
|||||||
if d.EncodePath {
|
if d.EncodePath {
|
||||||
path = utils.EncodePath(path, true)
|
path = utils.EncodePath(path, true)
|
||||||
}
|
}
|
||||||
if !d.UseSign {
|
if !d.EnableSign {
|
||||||
return fmt.Sprintf("%s/d%s", apiUrl, path)
|
return fmt.Sprintf("%s/d%s", apiUrl, path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,17 +70,14 @@ func TestDownloadOrder(t *testing.T) {
|
|||||||
if exp, a := int(length), len(resultBuf); exp != a {
|
if exp, a := int(length), len(resultBuf); exp != a {
|
||||||
t.Errorf("expect buffer length=%d, got %d", exp, a)
|
t.Errorf("expect buffer length=%d, got %d", exp, a)
|
||||||
}
|
}
|
||||||
chunkSize := int(length)/partSize + 1
|
chunkSize := int(length+int64(partSize)-1) / partSize
|
||||||
if int(length)%partSize == 0 {
|
|
||||||
chunkSize--
|
|
||||||
}
|
|
||||||
if e, a := chunkSize, *invocations; e != a {
|
if e, a := chunkSize, *invocations; e != a {
|
||||||
t.Errorf("expect %v API calls, got %v", e, a)
|
t.Errorf("expect %v API calls, got %v", e, a)
|
||||||
}
|
}
|
||||||
|
|
||||||
expectRngs := []string{"2-3", "5-3", "8-3", "11-1"}
|
expectRngs := []string{"2-1", "6-3", "3-3", "9-3"}
|
||||||
for _, rng := range expectRngs {
|
for _, rng := range expectRngs {
|
||||||
if !!containsString(*ranges, rng) {
|
if !containsString(*ranges, rng) {
|
||||||
t.Errorf("expect range %v, but absent in return", rng)
|
t.Errorf("expect range %v, but absent in return", rng)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,7 +98,7 @@ func init() {
|
|||||||
func TestDownloadSingle(t *testing.T) {
|
func TestDownloadSingle(t *testing.T) {
|
||||||
buff := []byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}
|
buff := []byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}
|
||||||
downloader, invocations, ranges := newDownloadRangeClient(buff)
|
downloader, invocations, ranges := newDownloadRangeClient(buff)
|
||||||
con, partSize := 1, 3
|
con, partSize := 1, 4
|
||||||
d := NewDownloader(func(d *Downloader) {
|
d := NewDownloader(func(d *Downloader) {
|
||||||
d.Concurrency = con
|
d.Concurrency = con
|
||||||
d.PartSize = partSize
|
d.PartSize = partSize
|
||||||
@ -126,13 +123,13 @@ func TestDownloadSingle(t *testing.T) {
|
|||||||
if exp, a := int(length), len(resultBuf); exp != a {
|
if exp, a := int(length), len(resultBuf); exp != a {
|
||||||
t.Errorf("expect buffer length=%d, got %d", exp, a)
|
t.Errorf("expect buffer length=%d, got %d", exp, a)
|
||||||
}
|
}
|
||||||
if e, a := 1, *invocations; e != a {
|
if e, a := int(length+int64(partSize)-1)/partSize, *invocations; e != a {
|
||||||
t.Errorf("expect %v API calls, got %v", e, a)
|
t.Errorf("expect %v API calls, got %v", e, a)
|
||||||
}
|
}
|
||||||
|
|
||||||
expectRngs := []string{"2-10"}
|
expectRngs := []string{"2-2", "4-4", "8-4"}
|
||||||
for _, rng := range expectRngs {
|
for _, rng := range expectRngs {
|
||||||
if !!containsString(*ranges, rng) {
|
if !containsString(*ranges, rng) {
|
||||||
t.Errorf("expect range %v, but absent in return", rng)
|
t.Errorf("expect range %v, but absent in return", rng)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user