Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alist-org
GitHub Repository: alist-org/alist
Path: blob/main/internal/model/args.go
1560 views
1
package model
2
3
import (
4
"context"
5
"io"
6
"net/http"
7
"time"
8
9
"github.com/alist-org/alist/v3/pkg/http_range"
10
"github.com/alist-org/alist/v3/pkg/utils"
11
)
12
13
type ListArgs struct {
14
ReqPath string
15
S3ShowPlaceholder bool
16
Refresh bool
17
}
18
19
type LinkArgs struct {
20
IP string
21
Header http.Header
22
Type string
23
HttpReq *http.Request
24
Redirect bool
25
}
26
27
type Link struct {
28
URL string `json:"url"` // most common way
29
Header http.Header `json:"header"` // needed header (for url)
30
RangeReadCloser RangeReadCloserIF `json:"-"` // recommended way if can't use URL
31
MFile File `json:"-"` // best for local,smb... file system, which exposes MFile
32
33
Expiration *time.Duration // local cache expire Duration
34
IPCacheKey bool `json:"-"` // add ip to cache key
35
36
//for accelerating request, use multi-thread downloading
37
Concurrency int `json:"concurrency"`
38
PartSize int `json:"part_size"`
39
}
40
41
type OtherArgs struct {
42
Obj Obj
43
Method string
44
Data interface{}
45
}
46
47
type FsOtherArgs struct {
48
Path string `json:"path" form:"path"`
49
Method string `json:"method" form:"method"`
50
Data interface{} `json:"data" form:"data"`
51
}
52
53
type ArchiveArgs struct {
54
Password string
55
LinkArgs
56
}
57
58
type ArchiveInnerArgs struct {
59
ArchiveArgs
60
InnerPath string
61
}
62
63
type ArchiveMetaArgs struct {
64
ArchiveArgs
65
Refresh bool
66
}
67
68
type ArchiveListArgs struct {
69
ArchiveInnerArgs
70
Refresh bool
71
}
72
73
type ArchiveDecompressArgs struct {
74
ArchiveInnerArgs
75
CacheFull bool
76
PutIntoNewDir bool
77
}
78
79
type RangeReadCloserIF interface {
80
RangeRead(ctx context.Context, httpRange http_range.Range) (io.ReadCloser, error)
81
utils.ClosersIF
82
}
83
84
var _ RangeReadCloserIF = (*RangeReadCloser)(nil)
85
86
type RangeReadCloser struct {
87
RangeReader RangeReaderFunc
88
utils.Closers
89
}
90
91
func (r *RangeReadCloser) RangeRead(ctx context.Context, httpRange http_range.Range) (io.ReadCloser, error) {
92
rc, err := r.RangeReader(ctx, httpRange)
93
r.Closers.Add(rc)
94
return rc, err
95
}
96
97
// type WriterFunc func(w io.Writer) error
98
type RangeReaderFunc func(ctx context.Context, httpRange http_range.Range) (io.ReadCloser, error)
99
100